안드로이드 개발시 흔하게 보이는 에러중에 하나입니다.
보통 입출력 관련 에러에서 흔하게 발생합니다.
예를 들면 파일을 기록하거나 읽어올때 발생합니다.
사실, 개발하다보면 여러가지 경우에 발생하는게 바로 IOException입니다.
1. 에러
-. 아래는 에러 발생시의 로그입니다.
error: unreported exception IOException; must be caught or declared to be thrown
input.readLine();
2. 에러 코드 (오류 포함)
3. 해결 방법
-. 위 에러의 경우는 에러 발생 가능성이 있는 부분에 throw 처리를 안하고 있기 때문입니다.
아래처럼 throw 할 수 있는 exception을 추가해주면 문제는 자연스럽게 해결이 됩니다.
4. 백서 (white paper)
Signals that an I/O exception of some sort has occurred. This class is the general class of exceptions produced by failed or interrupted I/O operations.
Summary
Constructs an IOException with null as its error detail message. |
Constructs an IOException with the specified detail message. |
Constructs an IOException with the specified detail message and cause. |
Constructs an IOException with the specified cause and a detail message of (cause==null ? null : cause.toString()) (which typically contains the class and detail message of cause). |
Public constructors
IOException
IOException()
Constructs an IOException with null as its error detail message.
IOException
IOException(message: String!)
Constructs an IOException with the specified detail message.
message | String!: The detail message (which is saved for later retrieval by the getMessage() method) |
IOException
IOException(
message: String!,
cause: Throwable!)
Constructs an IOException with the specified detail message and cause.
Note that the detail message associated with cause is not automatically incorporated into this exception's detail message.
message | String!: The detail message (which is saved for later retrieval by the getMessage() method) |
cause | Throwable!: The cause (which is saved for later retrieval by the getCause() method). (A null value is permitted, and indicates that the cause is nonexistent or unknown.) |
IOException
IOException(cause: Throwable!)
Constructs an IOException with the specified cause and a detail message of (cause==null ? null : cause.toString()) (which typically contains the class and detail message of cause). This constructor is useful for IO exceptions that are little more than wrappers for other throwables.
cause | Throwable!: The cause (which is saved for later retrieval by the getCause() method). (A null value is permitted, and indicates that the cause is nonexistent or unknown.) |
'안드로이드 개발' 카테고리의 다른 글
[수정완료] FAILURE: Build failed with an exception. (0) | 2023.05.11 |
---|---|
OutOfMemoryException 해결 방법 (0) | 2023.05.10 |
Default Activity not found 해결 방법 (0) | 2023.05.10 |
error: unreachable statement 해결 방법 (0) | 2023.05.09 |
The project uses Gradle 4.4 which is incompatible with Java 11 or newer. (0) | 2023.05.08 |