我有單列中的字符串列表。我想從這些字符串中創建三列,然後將輸出打印到另一個文件。我該怎麼做呢?如何將字符串拆分爲列
這是我到目前爲止已經試過:
ArrayList<String> list=new ArrayList<String>();
File file = new File("f://file.txt");
try {
Scanner scanner = new Scanner(file);
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
System.out.println(line);
}
scanner.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
我的輸入數據:
City
Gsk
Relocation
sripallu
here
jrajesh
gurgaon
unitech
StatisticsThreads
WizOty
LTDParsvnathK
Quotesby
newest
PMaashuktr
我的預期輸出:
City Gsk Relocation
sripallu here jrajesh
gurgaon unitech StatisticsThreads
WizOty LTDParsvnathK Quotesby
newest PMaashuktr Loans
.
.
.
.
.
.
.
你打算如何分割列?什麼是分隔符? – Swapnil
輸出的分隔符或分隔符的分隔符? –
'我的代碼我試過'我看不到任何邏輯在這裏拆分列。這不是一個嘗試! –