注册 登录
编程论坛 JAVA论坛

运行错误,请问怎么改?

_Strike 发布于 2016-10-13 08:38, 2455 次点击
package chapter.second;
import
public class JSysteminReadTest {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
              byte[] b=new byte[100];
              int count=System.in.read(b);
                      for(int i=0;i<=count-1;i++)
                      {
                         System.out.print((char)b[i]);
                      }
    }

}
只有本站会员才能查看附件,请 登录



6 回复
#2
_Strike2016-10-13 09:14
只有本站会员才能查看附件,请 登录
#3
_Strike2016-10-17 22:03
有大神吗?
#4
word1232016-10-18 22:50
是不是异常哦,捕获就行了try{}catch(){}    或者抛异常
#5
gp11366120502016-10-21 16:22
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        byte[] b = new byte[100];
        int count;
        try {
            count = System.in.read(b);
            for (int i = 0; i <= count - 1; i++) {
                System.out.print((char) b[i]);
            }
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
#6
孤独与烈酒2016-10-21 17:10
只有本站会员才能查看附件,请 登录

红线地方加上try-catch块就好了
#7
无限心2016-10-23 10:17
try catch一下
1