...
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 检索天气更新。我确实让它工作了,但它没有解析整个文档(最后一点的剪辑)。我做错了什么?