//創建 字節 數組 ?輸入流 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()的輸出結果會不一樣呢?求解答
添加回答
舉報
0/150
提交
取消