有人对如何更好地调试有任何建议吗?我知道line = in.readLine()
即使它不应该返回 null 。上一层我为所有人添加了一个捕获,throwables
但不幸的是,没有打印任何错误。有人对我接下来可以尝试什么有任何建议吗?
public static String pullString(int id) throws IOException {
String price;
logError("Checkpoint 1");
URL url = new URL("http://www.example.com");
URLConnection con = url.openConnection();
logError("Checkpoint 2");
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
logError("Checkpoint 3");
String line;
while ((line = in.readLine()) != null) {
//^ for some reason this becomes null, but on identical pages it works fine.
//Removed unneeded info
return ---;
} catch (NumberFormatException e) {
logError("NumberFormatException");
return null;
}
}
}
logError("left out the back");
return null;
}