【发布时间】:2016-03-23 18:05:04
【问题描述】:
我正在尝试编写一个可以将响应保存到文件的 GET 处理程序。
public String get(String[] args) throws IOException {
URL url = new URL(args[1]);
BufferedReader input = new BufferedReader(new InputStreamReader(url.openStream()));
String output = "";
String line = input.readLine();
while(line != null){
output += line + "\n";
line = input.readLine();
}
saveGetToFile(output);
return "Response saved to: " + path.toString();
}
但是,它似乎总是返回两次响应。我在这里缺少一些逻辑吗?它返回整个响应,然后再次返回整个响应。
【问题讨论】: