가능한 중복 : 나는 다음과 같은 알고리즘을 사용하여 오일러 # 8를 해결하기 위해 노력하고있어
Why do I get the “Unhandled exception type IOException”?처리되지 않은 예외 유형 IOException이
. 문제는 내가 거대한 주석이있는 행을 수정할 때 //###
이라고 표시된 행에 오류 Unhandled Exception Type IOException
이 표시된다는 것입니다.
private static void euler8()
{
int c =0;
int b;
ArrayList<Integer> bar = new ArrayList<Integer>(0);
File infile = new File("euler8.txt");
BufferedReader reader = new BufferedReader(
new InputStreamReader(
new FileInputStream(infile), //###
Charset.forName("UTF-8")));
while((c = reader.read()) != -1) { //###
char character = (char) c;
b = (int)character;
bar.add(b); /*When I add this line*/
}
reader.close(); //###
}
[예외 자습서] 읽기 (http://docs.oracle.com/javase/tutorial/essential/exceptions/index.html) 다음에 그 지식을 사용
또는 예외를 잡을 try/catch에 코드를 래핑하거나 예외를 던지십시오. –