樣本數據文件INV1,A,BB,,,,INV2,A,CC,,,,INV3,C,BB,,,,陣列僅獲得第一行的 INV1 A 和 BB,類似地獲得第二行的 INV2 a 和 CC,以及第三行的 INV3 C 和 BB。其余值不予考慮。我的代碼 BufferdReader bReader = new BufferedReader (new FileReader(/home/test.txt)); String line = ""; while ((line = bReader.readLine ()) !=null) { if (line != null){ String[] array = line.split(",") ; for (String arrays : array ) { System.out.println(arrays ); }}}輸出 :INV1ABBINV2ACCINV3CBB預期輸出INV1ABBINV2ACCINV3CBB
添加回答
舉報
0/150
提交
取消