用这个
try{
String txt = "";
URL url = new URL("URL地址");
URLConnection urlc = url.openConnection();
urlc.connect;
InputStream is = urlc.getInputStream();
....
is.close();
}
catch(Exception e){
}
try{
String txt = "";
URL url = new URL("URL地址");
URLConnection urlc = url.openConnection();
urlc.connect;
InputStream is = urlc.getInputStream();
....
is.close();
}
catch(Exception e){
}
解决方案 »
- 大家帮忙看看这个对象序列化的问题 十分感谢!!
- 共500分!!!Java awt 如何将输出到屏幕上的图像输出到图片 如果有好思路另开帖子另给分
- 如何解决java.util.ConcurrentModificationException
- java反射机制的几个问题!
- jComboBox遇到的问题
- java IO的文件分割问题(请看代码)
- 初学者问题
- java中怎么读写windows注册表。
- 移动图片上加小图片?
- 困惑很久的问题,一个实体BEAN只能对应一个TABLE吗?如果有几百个TABLE,难道要写几百个实体BEAN?
- 用Java做WEBGIS用什么做比较好?
- java中一个参数想传到一个jsp里,即使这个java页关闭,参数也不消失,该怎么传~
URLConnection con = (new URL(url)).openConnection();
try {
con.setDoOutput(true);
con.setUseCaches(false);
con.setRequestProperty("Content-Type", "text/plain");
System.out.println(con.getContentLength());
System.out.println("Sending data... ...");
if (con.getContentLength() > 0) {
int s;
byte[] buf = new byte[4096];
while ((s = con.getInputStream().read(buf)) != -1) {
。。
}
}
System.out.println("Scope ended.");
}
catch (Exception e) {
e.printStackTrace();
}
finally {
try {
fos.close();
}
catch (Exception e) {}
try {
con.getInputStream().close();
}
catch (Exception e) {}
try {
con.getOutputStream().close();
}
catch (Exception e) {}
}