java - Why Writting on txt file is different from console? -


i want save arraylist in txt file, used printwriter. table, used string.format method. when writing data on console, perfect. when writing on txt file different.

why different when writing in txt file console. see in below image?

different txt output

it's because of tabs (\t) using. apparently notepad has different way of displaying tabs console. might able use string.format formatting, instead of adding tabs yourself, check the javadoc that.

see this question solution, example:

string.format("%s, %s, %-20s%n", firstname, lastname, phonenumber) 

edit additional tip: can add %n in format string platform specific newline (added in above example).


Comments