相关疑难解决方法(0)

为什么我会收到"未处理的异常类型IOException"?

我有以下简单的代码:

import java.io.*;
class IO {
    public static void main(String[] args) {    
       BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));    
       String userInput;    
       while ((userInput = stdIn.readLine()) != null) {
          System.out.println(userInput);
       }
    }
}
Run Code Online (Sandbox Code Playgroud)

我收到以下错误消息:

----------
1. ERROR in io.java (at line 10)
    while ((userInput = stdIn.readLine()) != null) {
                        ^^^^^^^^^^^^^^^^
Unhandled exception type IOException
----------
1 problem (1 error)roman@roman-laptop:~/work/java$ mcedit io.java 
Run Code Online (Sandbox Code Playgroud)

有人有什么想法吗?我只是想简化总和网站上给出的代码(这里).我过度简化了吗?

java stdin readline ioexception

33
推荐指数
3
解决办法
16万
查看次数

标签 统计

ioexception ×1

java ×1

readline ×1

stdin ×1