我在下面的代码的结尾花括号中得到这些错误。有人能告诉我为什么会出现这些错误吗?我认为代码的意思是用大括号结尾。
String line = "";
while ((line = reader.readLine()) != null) {
buffer.append(line);
}
movieData.setText(buffer.toString());
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
//will check if connection is running or not and will disconnect accordingly
if (connection != null) {
connection.disconnect();
}
try {
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
答案 0 :(得分:0)
您忘记在最后添加catch
阻止:
try {
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
catch (Exception e) { // Add catch block to handle potential exception
e.printStackTrace();
}
(考虑到您在try
之前开始使用String line = "";
阻止