不能直接用 File file = new File("http://127.0.0.1:8080/aa.txt") 来读取,因为网络上的传输协议为HTTP,与
本地不同,要用URL来读取
String output="";
File file = new File("E://bb.txt");
URL MyURL = new URL("http://127.0.0.1:8080/aa.txt");
URLConnection uc=MyURL.openConnection();
uc.connect();
InputStreamReader _Input=new InputStreamReader(uc.getInputStream(),"UTF-8");
BufferedReader br=new BufferedReader(_Input);
String s="";
while((s=br.readLine())!=null){
output+=s;
}
FileWriter fw=new FileWriter(file);
fw.write(output);
fw.flush();
fw.close();