1 Attachment(s)
Supressing empty lines and does not do until the end! Why ?
Hi guys,
I really don't understand what's happening in my program, almost mad!
Basically, it just takes a file in input and outputs a file.
What it tries to do is just suppress all the empty lines, very simple.
Here is the body of my method :
Code :
private static void suppressSpaces(String in, String out) {
try {
FileReader fr = new FileReader(in);
FileWriter fw = new FileWriter(out);
BufferedReader br = new BufferedReader(fr);
PrintWriter pw = new PrintWriter(fw);
String inLine = null;
while ((inLine = br.readLine()) != null) {
if (inLine.trim().length() != 0) {
pw.println(inLine);
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
The input file has 20'609 lines to process and I don't understand why but it kind of stops processing after the line 20'350 about. So in the output file, there is about 97-98% of what there should be normally. No idea why...The file is very regular, I mean there is nothing special at the line 20'350, it's just the same as before.
I attached a sample input file in TXT format (the whole file exceeds the limit), please have a look if you want.
Here are the 10 last lines of the output file :
Code :
1336咸
BAB0 喊 han3
BCEA 缄 jian1
BCEE 碱 jian3
BCF5 减 jian3
CFCC 咸 xian2
F3F0 箴 zhen1
1337感
B8D0 感 gan3
BAB3
You can see it stops in the middle of the category 1337 and there is total of 1353 categories so it's almost done but dunno why, it doesn't go until the end!!
Anyone has an idea ?
Thanks in advance for your help guys!
Re: Supressing empty lines and does not do until the end! Why ?
Just found the answer -.-
Needs to perform the flush() method on the PrintWriter at the end and yeah...it flushes what was not output before ^^
Jeez!