用Java向Web站点发送POST请求,怎么实现? http://www.javayou.com/showlog.jspe?cat_id=-1&log_id=472 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 谢谢. 但是我想要使用Java API来实现的. 楼主,数据应该转用byte方式或ASCII码方式来传,否则在paramBuffer.toString()有一些特殊字符影响两边的交互。//connect serverURL objURL = new URL(strProcessURL);//open connectURLConnection objConn = objURL.openConnection();objConn.setDoOutput(true);//get server return message// BufferedInputStream objInput = new BufferedInputStream(objConn.getInputStream());StringBuffer strTempBuf = new StringBuffer();byte[] byteArray = new byte[2048];int nReadCount = -1;BufferedOutputStream objOutput = new BufferedOutputStream(objConn.getOutputStream());FileInputStream objFileIn = new FileInputStream("c:\\test.txt");while ((nReadCount = objFileIn.read(byteArray)) != -1) { objOutput.write(byteArray, 0, nReadCount);}objOutput.flush();objFileIn.close();objOutput.close(); Class和Class<?>有什么区别? request 和 response跳转意义? 通过JDBC如何获取TEST数据库表的结构 提问关于java后台调用外部程序的问题 notify两个问题 怎样才能取得TreeMap 键和值? 高分请教:如何将一个对象完全克隆到另外一个新对象里面呢? 问几个小问题 socket服务器端与客户端的连接 收购 --- 任何 B/S结构的软件 如何正确使用jar打包发布class文件? 水晶报表格式的问题:怎么动态显示或隐藏page header?
URL objURL = new URL(strProcessURL);
//open connect
URLConnection objConn = objURL.openConnection();
objConn.setDoOutput(true);
//get server return message
// BufferedInputStream objInput = new BufferedInputStream(objConn.getInputStream());
StringBuffer strTempBuf = new StringBuffer();
byte[] byteArray = new byte[2048];
int nReadCount = -1;
BufferedOutputStream objOutput =
new BufferedOutputStream(objConn.getOutputStream());
FileInputStream objFileIn = new FileInputStream("c:\\test.txt");
while ((nReadCount = objFileIn.read(byteArray)) != -1) {
objOutput.write(byteArray, 0, nReadCount);
}
objOutput.flush();
objFileIn.close();
objOutput.close();