2012-11-08 58 views

回答

2
String data = ""; 
try { 
    // Create a URL for the desired page 
    URL url = new URL("http://myserver.com/abc.txt"); 
    BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); 
    String str; 
    while ((str = in.readLine()) != null) { 
     data += str + "\n" 
    } 
    in.close(); 
} catch (MalformedURLException e) { 
} catch (IOException e) { 
} 
System.out.println(data); 

你不能創建一個文件,你必須使用讀者。