0
...網絡爬蟲的Java
public static void download() {
try {
URL oracle = new URL("http://api.wunderground.com/api/54f05b23fd8fd4b0/geolookup/conditions/forecast/q/US/CO/Denver.json");
BufferedReader in = new BufferedReader(new InputStreamReader(oracle.openStream()));
File file = new File("C:\\Users\\User\\Desktop\\test2.json");
if (!file.exists()) {
file.createNewFile();
}
FileWriter fw = new FileWriter(file.getAbsoluteFile());
BufferedWriter bw = new BufferedWriter(fw);
String inputLine;
while ((inputLine = in.readLine()) != null) {
bw.write(inputLine+"\n");
}
fw.close();
in.close();
System.out.println("Finished...");
}
catch(MalformedURLException e){e.printStackTrace();}
catch(IOException e){e.printStackTrace();}
}
我正在做一個網絡爬蟲從Wunderground獲取天氣信息。我確實得到了這個工作,但它不解析整個文檔(最後一位的剪切)。我做錯了什麼?
沖洗你的'bw'。 –
更好地關閉你的'bw'。 –
@SotiriosDelimanolis哈哈感謝:/,它現在可以工作 – Arc