Java tabs ("\t") not working using FileWritter

As you can see, after every text comes a tab, everything is working fine, but after third tab (see output) it generates a space not a tab.

fileWriter = new FileWriter(indexFile, true);
fileWriter.append(id).append("\t");
fileWriter.append(String.valueOf(idx)).append("\t");
fileWriter.append(String.valueOf(pageCount)).append("\t");
fileWriter.append(postal.toUpperCase()).append("\t"); <-- this one
fileWriter.append(address.toUpperCase());
fileWriter.append("\r\n");

My output:

00000347    1   1   FB-6666 DUMMY STREET 1 LAT

The problem comes after "FB-6666".

Any ideas on this?

Jon Skeet
people
quotationmark

No, it really is generating a tab - it's just that whatever you're using to view the file is deciding to handle tabs by aligning them to some boundary or other. If you make your postal value FB-6666x I suspect you'll then see a much larger space.

This isn't a problem with the file content at all.

If you want to enforce a certain number of spaces between columns, you'll need to write that many spaces. Alternatively, something else to view the file...

people

See more on this question at Stackoverflow