如何用post将xml文件发到网络上 如何用post将xml文件发到网络上。求解。。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 xml文件是么?Apache的HttpEntity接口有一个实现类FileEntity用xml文件生成这个对象,然后HttpClient用post方式通信就好了 private DefaultHttpClient httpClient; private HttpEntity httpEntity; private HttpResponse httpResponse; private HttpPost httpPost; public void doPost(String url, String filePath) { try { httpClient = new DefaultHttpClient(); httpPost = new HttpPost(url); httpEntity = new FileEntity(new File(""), "text/xml"); httpPost.setEntity(httpEntity); httpResponse = httpClient.execute(httpPost);} catch (Exception e) { } finally { httpClient.getConnectionManager().shutdown(); }}大概就是这样了,httpResponse就是你得到的响应,根据情况再转类型吧还有,new FileEntity的第二个参数是contentType,根据你实际上传的文件格式确定 ubuntu中安装了JDK 但不能用javah命令 SQLite执行sql语句出错。。。。。。。。。 关于contentProvider的问题 java.lang.IllegalArgumentException: Unknown URL content://x 如何手动方式查看类的方法 android 启动项目的问题 android 求助啊。救命。 发布一个软件 android客户端rest使用 DDMS有对外的接口可以在程序中调用么? JAVA中如何向SQL数据保存图片文件 android短信草稿箱草稿删除的问题 一个颜色替换的问题
Apache的HttpEntity接口有一个实现类FileEntity
用xml文件生成这个对象,然后HttpClient用post方式通信就好了
private HttpEntity httpEntity;
private HttpResponse httpResponse;
private HttpPost httpPost;
public void doPost(String url, String filePath)
{
try
{
httpClient = new DefaultHttpClient();
httpPost = new HttpPost(url);
httpEntity = new FileEntity(new File(""), "text/xml");
httpPost.setEntity(httpEntity);
httpResponse = httpClient.execute(httpPost);
} catch (Exception e)
{
} finally
{
httpClient.getConnectionManager().shutdown();
}
}大概就是这样了,httpResponse就是你得到的响应,根据情况再转类型吧
还有,new FileEntity的第二个参数是contentType,根据你实际上传的文件格式确定