-1

文本文件中的字符串是这样的:

    Fulton County 6
    County Grand 1
    Grand Jury 2
    Jury said 1
    said Friday 4
    Friday an 1
    an investigation 5
    investigation of 15
    of Atlanta's 1
    Atlanta's recent 1
    recent primary 1
    primary election 2
    election produced 1
    produced `` 1
    `` no 6

我想从中读取并重新打印到另一个文本文件中,格式如下:

    Fulton County           6
    County Grand            1
    Grand Jury              2
    Jury said               1
    said Friday             4
    Friday an               1
    an investigation        5
    investigation of        15
    of Atlanta's            1
    Atlanta's recent        1
    recent primary          1
    primary election        2
    election produced       1
    produced ``             1
    `` no                   6
4

2 回答 2

0

您可以使用来自 apache commons lang 的StringUtils - 检查这个http://commons.apache.org/lang/api-2.5/org/apache/commons/lang/StringUtils.html和特别严重的rightPad方法

于 2012-07-27T07:13:13.493 回答
0

您可以使用 regexp " (\d+)" 查看String .replaceAll,然后将其替换为包含 \t + digit 的字符串以用于制表符

于 2012-07-27T07:14:11.713 回答