'Try without catch error',')' 预期,表达式的非法开始..?
'Try without catch error', ')' expected, illegal start of expression..?
我在下面代码的结尾花括号中遇到了这些错误。有人能告诉我为什么会出现这些错误吗?我以为代码应该以大括号结尾。
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();
}
}
}
}
您忘记在末尾添加catch
块:
try {
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
catch (Exception e) { // Add catch block to handle potential exception
e.printStackTrace();
}
(考虑到您在 String line = "";
之前以 try
块 开始)
我在下面代码的结尾花括号中遇到了这些错误。有人能告诉我为什么会出现这些错误吗?我以为代码应该以大括号结尾。
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();
}
}
}
}
您忘记在末尾添加catch
块:
try {
try {
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
catch (Exception e) { // Add catch block to handle potential exception
e.printStackTrace();
}
(考虑到您在 String line = "";
之前以 try
块 开始)