我在这样的记事本中有一个文本字符串
记事本中的文本:
date amount intrest tenure debitamount name address state city zipcode phone altphone mailid refaddress ref refphoneno emptype employment
12/11/1987 12345 3.5 144 32456 durga f rao 456 under road
dallas dl 2435 2222-22-2222 2222-22-2222 durgafrao@gmail.com
165 nala road raj 22-22-22-2222 it 12
15/05/1986 2345 6.4 144 45789 rama k nand 789 residensy
newyork ny 2222-22-2222 2222-22-2222 ramaknand@yahoomail.com
189 ring road hen 22-22-22-22-2222 it 12
16/12/1985 1234 6.5 144 35265 rama j rao 123 dura residensy meknoor
mn 2222-22-2222 2222-22-2222 ramajrao@orkut.com 891 cing road vinky
22-22-22-2222 it 12
12/11/1987 12345 3.5 144 32456 durga f rao 456 under road dallas dl
2435 2222-22-2222 2222-22-2222 durgafrao@gmail.com 165 nala road raj
22-22-22-2222 it 12
out put should be like below
in between name and address single space and all other double space
12/11/1987 12345 3.5 144 32456 durga f rao 456 under road
dallas dl 2435 2222-22-2222 2222-22-2222 durgaao@gmail.com
165 nala road raj 22-22-22-2222 it 12
15/05/1986 2345 6.4 144 45789 rama k nand 789 residensy
newyork ny 2222-22-2222 2222-22-2222 ramaad@yahoomail.com
189 ring road hen 22-22-22-22-2222 it 12
16/12/1985 1234 6.5 144 35265 rama j rao 123 dura residensy meknoor
mn 2222-22-2222 2222-22-2222 ramajo@orkut.com 891 cing road vinky
22-22-22-2222 it 12
12/11/1987 12345 3.5 144 32456 dura f rao 456 under road dallas dl
2435 2222-22-2222 2222-22-2222 durga@gmail.com 165 nala road raj
22-22-22-2222 it 12
我希望我的输出应该像下面在名称和地址单个空格和所有其他双空格之间?
我写了下面的代码,但我无法得到想要的输出
任何人都可以帮助我吗?
我试过的代码:
public static String newLine = System.getProperty("line.separator");
public static void main(String args[]){
FileWriter iWrite=null;
try {
iWrite = new FileWriter("C:/Documents and Settings/pavan/My Documents/output.txt");
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
List<String> lines = FileUtils.readLines(new File("C:/Documents and Settings/pavan/My Documents/input.txt"));
for(String lines1:lines){
iWrite.write(lines1);
iWrite.write(newLine);
}
iWrite.close();
} catch (IOException e) {
e.printStackTrace();
}
}