Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

writing a table to a file

Status
Not open for further replies.

tictaclam

Programmer
Jan 8, 2004
47
US
Hi
I am creating a file with the contents of a table. I have no problem writing the data to the file but is there any good way to format the data? I would like the file to contain columns. The length of the data in the table varies and I didn't have much luck playing around with inserting tabs. I would like it to be something like this:

column 1 column2 column3
some information 12 more info
info 1323 other info
stuff 1 info

I am not sure if there is any easy way to do this. I am using PrintWriter to write to the file
Thanks
 
If it's okay to write to a html-file, you could use that, and don't have to think about column-width.

Drawbacks: Harder to reread for your program, bigger filesize, needs a specialized viewer to look at it.

To format it as plain text, you would have to iterate through all rows first, and get the maximum entry-length for each column, and fill in some tabs.

seeking a job as java-programmer in Berlin:
 
I can't use a html-file so that's out. I figured i would have to iterate through the text. I was hoping there was an easier way. Oh well thanks though
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top