就是这个问题,
我之前是想把xml文件写到ByteArrayOutputStream流里,可是怎么写到网络就不知道了
另外
URL url = new URL("http://www.scu.edu.cn/");
InputStream is = url.openStream();把流连到哪个url上,可是这能读
所以这个怎么办
------解决方案--------------------
/**
*
* @param url 发送数据的URL
* @param param post的数据
* @param charSet 设置服务端返回数据编码方式
* @return 服务端返回数据
*/
public String sendPost(String url, String param, String charSet) {
String result = "";
this.log.info("param:" + param);
this.log.info("url:" + url);
if ((url == null)
------解决方案--------------------
("".equals(url))) {
return result;
}
try {
URL httpurl = new URL(url);
HttpURLConnection httpConn = (HttpURLConnection) httpurl
.openConnection();
httpConn.setDoOutput(true);
httpConn.setDoInput(true);
httpConn.setRequestMethod("POST");
PrintWriter out = new PrintWriter(httpConn.getOutputStream());
out.print(param);
out.flush();
out.close();
BufferedReader in = new BufferedReader(new InputStreamReader(
httpConn.getInputStream(), charSet));
String line;
while ((line = in.readLine()) != null) {
result = result + line;
}
in.close();
} catch (Exception e) {
this.log.error("no result!" + e);
}
return result;
}
------解决方案--------------------
使用http协议完全可以解决楼主的问题,请参考http://hi.baidu.com/wzgws/item/778facc12c7b6b2c46d5c035