java 发请求到远程服务器 java中发一个请求到远程服务器上,远程服务器根据传过来的参数得到结果,再返回到发送处请教实现思路?,最好详细一点,谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 可以用webservice http://topic.csdn.net/u/20110705/19/3f827b69-78bb-46f2-b61a-b46e917cbc76.html?54846 或者自己写个servlet。然后import java.io.File;import java.io.FileWriter;import java.io.IOException;import java.io.PrintWriter;public class Test1 { private static String getStaticPage(String surl) { String htmlContent = ""; try { java.io.InputStream inputStream; java.net.URL url = new java.net.URL(surl); java.net.HttpURLConnection connection = (java.net.HttpURLConnection) url .openConnection(); connection.connect(); inputStream = connection.getInputStream(); byte[] bytes = new byte[1024 * 2000]; int index = 0; int count = inputStream.read(bytes, index, 1024 * 2000); while (count != -1) { index += count; count = inputStream.read(bytes, index, 1); } htmlContent = new String(bytes, "UTF-8"); connection.disconnect(); } catch (Exception ex) { ex.printStackTrace(); } return htmlContent.trim(); } public static void main(String[] args) { try { String src = getStaticPage("http://www.google.com"); File file = new File("d:\\aa.html"); FileWriter resultFile = new FileWriter(file); PrintWriter myFile = new PrintWriter(resultFile);// 写文件 myFile.println(src); resultFile.close(); myFile.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }} 简单的做法就是 服务器上写个servlet 正则表达式提取串的问题 OpenSessionInViewFilter 过滤器的顺序对吗? 启动tomcat的时候出现的错误) weblogic问题,如何关闭页面缓冲 我的jstl为什么不支持EL比表达式 被打包成EAR,WAR,JAR的组件不能使用File I/O吗? 初学STRUTS请指教~~~要运行第一个struts需要在我的TOMCAT下怎么配置 关于认证考试的问题 J2SE和J2EE在开发和部署上有些什么不同吗? 现在常用的代吗维护工具都有那些呀?最好有详细的质料!! 在实际开发中遇到的一个纠结问题,不知是设计的问题还是~~~~ 语句执行了为什么在数据库是乱码?
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;public class Test1 {
private static String getStaticPage(String surl) {
String htmlContent = "";
try {
java.io.InputStream inputStream;
java.net.URL url = new java.net.URL(surl);
java.net.HttpURLConnection connection = (java.net.HttpURLConnection) url
.openConnection();
connection.connect();
inputStream = connection.getInputStream();
byte[] bytes = new byte[1024 * 2000];
int index = 0;
int count = inputStream.read(bytes, index, 1024 * 2000);
while (count != -1) {
index += count;
count = inputStream.read(bytes, index, 1);
}
htmlContent = new String(bytes, "UTF-8");
connection.disconnect();
} catch (Exception ex) {
ex.printStackTrace();
}
return htmlContent.trim();
} public static void main(String[] args) {
try {
String src = getStaticPage("http://www.google.com");
File file = new File("d:\\aa.html");
FileWriter resultFile = new FileWriter(file);
PrintWriter myFile = new PrintWriter(resultFile);// 写文件
myFile.println(src);
resultFile.close();
myFile.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}