为了账号安全,请及时绑定邮箱和手机立即绑定

IO流问题

IO流问题

AJohnson 2016-01-09 14:27:28
//创建 字节 数组  输入流 String intput ="elephant";//输入的字符串内容 byte[] buffer=intput.getBytes(); ByteArrayInputStream bais =new ByteArrayInputStream(buffer);//创建字节数组输入对象 for(int i=0;i<intput.length();i++){ while(((int)bais.read())!=-1){ System.out.println((char)bais.read()); } } 输出结果:lpat//创建 字节 数组  输入流 String intput ="elephant";//输入的字符串内容 byte[] buffer=intput.getBytes(); ByteArrayInputStream bais =new ByteArrayInputStream(buffer);//创建字节数组输入对象 for(int i=0;i<intput.length();i++){          int c; while((c=bais.read())!=-1){ System.out.println((char)c); } }输出结果:elephant为什么c=bais.read(),(char)c和(char)bais.read()的输出结果会不一样呢?求解答
查看完整描述

1 回答

  • 1 回答
  • 2 关注
  • 1313 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信