0

我从http://www.java2s.com/Code/Jar/h/Downloadhttpmimejar.htm下载 httpmime.jar

我把httpmime.jar放在jre7/lib/ext/的文件夹下

在下面的代码中出现错误 [此行有多个标记]

MultipartEntity entity = new MultipartEntity(
    HttpMultipartMode.BROWSER_COMPATIBLE); 

你能给点建议吗?谢谢

我的参考android的代码如下--------

 StringBuffer responseBody = new StringBuffer();  
 HttpClient client = new DefaultHttpClient();  
 client.getParams().setParameter(
     CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);  
 HttpPost post = new HttpPost("http://IP.IP.IP.IP/file_upload.php");  
 MultipartEntity entity = new MultipartEntity(
     HttpMultipartMode.BROWSER_COMPATIBLE);  
 entity.addPart("uploadedfile", new FileBody((FileObj), "application/zip")); 
 post.setEntity(entity);     
 ...    
4

2 回答 2

0

确保您在单独的网络连接上执行Thread,如本博文中所述。这通常是导致您可能遇到的奇怪错误的原因。在为 Android 开发应用程序时,请始终确保在单独的Thread(即使用)上执行可能代价高昂的操作。AsyncTask

于 2012-07-11T02:18:46.260 回答
0

想到两件事:

  • 在单独的线程上执行您的网络
  • 确保INTERNET在您的Manifest.xml

You should perform long tasks (such as network I/O) in separate thread from the main thread. In fact depending on the version of Android you're developing for, the JVM will raise a NetworkOnMainThreadException if you attempt to do networking on the main thread.

于 2012-07-11T03:22:06.490 回答