为什么!!!!!!!!!!!!!!!!!!!!!

darkfirexl 2006-02-21 05:41:23
public static void main(String[] args) {
try
{
DataInputStream di=new DataInputStream(System.in);
System.out.print(di.readInt());
}
catch(Exception ex)
{
System.out.print(ex.getMessage());
}
}

总是得到奇怪的答案!
java的IO流真麻烦,有什么好书可以介绍的?
...全文
131 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
darkfirexl 2006-02-23
  • 打赏
  • 举报
回复
我的代码不就是用DataInputStream包装,然后再用reanInt()读的吗
darkfirexl 2006-02-22
  • 打赏
  • 举报
回复
但是如果我要从流中读不同的数据类型呢,比如先读整形,再读浮点型
darkfirexl 2006-02-22
  • 打赏
  • 举报
回复
o
yanhan0615 2006-02-22
  • 打赏
  • 举报
回复
你可以用DataInputStream包装下,使用该类的readInt()或者readFloat()方法
andycpp 2006-02-21
  • 打赏
  • 举报
回复
System.in相当于一个StringBufferInputStream,
而DataInputStream应该去包装一个ByteArrayInputStream,
所以你这么弄肯定是错的了~~~~~
darkfirexl 2006-02-21
  • 打赏
  • 举报
回复
是的,但是我那段代码为什么不可以。+.+
mq612 2006-02-21
  • 打赏
  • 举报
回复
你是否想把自己输入的文字再显示出来?

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try {
System.out.println("return:" + br.readLine());
}
catch (IOException ex) {
}

62,615

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧