В настоящее время я разрабатываю приложение J2ME. У меня проблемы с загрузкой файлов. Кажется, я не знаю, какая часть моего кода неверна. Вот мой код:
public void UploadImage(long newFileId, String url, String bytes){
    HttpConnection conn = null;
      OutputStream os = null;
      InputStream s = null;
      StringBuffer responseString = new StringBuffer();
      try
      {
         System.out.println(System.getProperty("HTTPClient.dontChunkRequests"));
         conn.setRequestMethod(HttpConnection.POST);
         conn = (HttpConnection)Connector.open(url);
         conn.setRequestProperty("resumableFileId", ""+newFileId);
         conn.setRequestProperty("resumableFirstByte", ""+0);
         conn.setRequestProperty("FilePart", bytes);
         // Read
         s = conn.openInputStream();
         int ch, i = 0, maxSize = 16384;
         while(((ch = s.read())!= -1 ) & (i++ < maxSize)) 
         {
            responseString.append((char) ch);
         }
         conn.close();
         System.out.println(responseString.toString());
         String res = uploadFinishFile(newFileId, bytes);
         if(res.length()>0)
             System.out.println("File uploaded.");
         else
           System.out.println("Upload failed: "+res);
      }
      catch (Exception e)
      {
          System.out.println(e.toString());
      }
}
Это java-код, который я пытаюсь преобразовать в j2me:
try {
  HttpClient client = new DefaultHttpClient();
  HttpPost post = new HttpPost(url);
  MultipartEntity me = new MultipartEntity();
  StringBody rfid = new StringBody("" + newFileId);
  StringBody rfb = new StringBody("" + 0);
  InputStreamBody isb = new InputStreamBody(new BufferedInputStream(new FileInputStream(f)), "FilePart");
  me.addPart("resumableFileId", rfid);
  me.addPart("resumableFirstByte", rfb);
  me.addPart("FilePart", isb);
  post.setEntity(me);
  HttpResponse resp = client.execute(post);
  HttpEntity resEnt = resp.getEntity();
  String res = da.uploadFinishFile(login, password, newFileId, DigestUtils.md5Hex(new FileInputStream(f)));
  if(res.isEmpty())
  System.out.println("File uploaded.");
  else
    System.out.println("Upload failed: "+res);
} catch (Exception ex) {
  System.out.println("Upload failed: "+ex.getMessage());
}