How to remove all blank spaces and empty lines from a txt File using Java SE?
Input:
qwe
qweqwe
qwe
qwe
Output:
qwe
qweqwe
qwe
qwe
Thanks!
How to remove all blank spaces and empty lines from a txt File using Java SE?
Input:
qwe
qweqwe
qwe
qwe
Output:
qwe
qweqwe
qwe
qwe
Thanks!
Have a look at trim() function
http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/String.html#trim()
Also, some code would be helpful...
Remove spaces for each line and do not consider empty and null lines:
How about something like this:
Note - not tested, may not be perfect syntax but gives you an idea/approach to follow.
See the following JavaDocs for reference purposes: http://download.oracle.com/javase/7/docs/api/java/io/FileReader.html http://download.oracle.com/javase/7/docs/api/java/io/FileWriter.html