怎样从控制台输入中读取汉字??

hallosky 2003-10-06 04:57:52
我的代码片断如下:
BufferedReader userCommands= new BufferedReader(
new InputStreamReader(System.in));
while(true){
String str = userCommand.readLine();
System.out.println(str);
....
}

输入中文后,没有任何输出。看了以前的帖子后,转了一下编码,还是不行。请各位赐教。谢谢。
...全文
112 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
hallosky 2003-10-06
  • 打赏
  • 举报
回复
晕倒!!!现在行了!!!!!!!!送分!!!!!!!!1
newman0708 2003-10-06
  • 打赏
  • 举报
回复
InputStream child_in = System.in;
System.out.println (cmd);
BufferedReader in=new BufferedReader(new InputStreamReader(child_in));
String szstr1="";
int count=0;

while ((szstr1=in.readLine())!=null){
if(szstr1.equal("quit"))
break;
System.out.println(szstr1);
count++;
}
System.out.print("count: "+count);
child_in.close();
in.close() ;
child.destroy() ;
} catch (IOException e) {
System.err.println(e);
}
LoveRose 2003-10-06
  • 打赏
  • 举报
回复
我试了可以的啊
最好加上try catch 语句!

62,614

社区成员

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

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