当前位置: 代码迷 >> J2SE >> 谁知道下面的有关问题?
  详细解决方案

谁知道下面的有关问题?

热度:40   发布时间:2016-04-24 16:29:43.0
谁知道下面的问题?????????????
怎么样从网络上面读到一个文件(TXT)???????

------解决方案--------------------
import java.io.*;
import java.net.*;

public class lesson2 {
public static void main(String arg[]){
//
try
{
URL url = new URL( "http://community.csdn.net/Expert/topic/5452/5452629.xml?temp=.5713159/ ");
InputStream is = url.openStream();

BufferedReader in = new BufferedReader(
new InputStreamReader(is));
String readLine = in.readLine();;
while (readLine != null) {
System.out.println(readLine);
readLine = in.readLine();
}
}
catch(MalformedURLException m){
System.out.print( " ");
}
catch(IOException i){}
}
}
  相关解决方案