【发布时间】:2013-01-19 11:14:08
【问题描述】:
我在单列中有一个字符串列表。我想从这些字符串中创建三列,然后将输出打印到另一个文件。我该怎么做?
这是我迄今为止尝试过的:
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
.
.
.
.
.
.
.
【问题讨论】:
-
您打算如何拆分列?分隔符是什么?
-
分割分隔符还是输出分隔符?
-
My code what I tried我在这里看不到任何拆分列的逻辑。这不是一个尝试! -
@NarendraPathai OP 说拆分只需要一列
-
你不能仅仅通过发布一些甚至不值得尝试的代码来逃避!
标签: java