This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes How to easily write a text file with beautiful format Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to easily write a text file with beautiful format " Watch "How to easily write a text file with beautiful format " New topic
Author

How to easily write a text file with beautiful format

Pira Tomatsu
Greenhorn

Joined: Sep 01, 2009
Posts: 14
Hi everyone,

I'm a java beginner. I need to write text from database into a beautiful format text file such as a POS slip format.
Can you give me an advice of what I need to know to do things like this.

Thank you very much
Karina Guenther
Ranch Hand

Joined: Sep 16, 2005
Posts: 50
One method is to write your output as comma delimited format using BufferedWriter that your user can open in a spreadsheet. The spreadsheet program then organizes your information in the way you want it.

BufferedWriter out = new BufferedWriter(new OutputStreamWriter(response
.getOutputStream()));

If this is interactive and you are returning the data as part of a gui response, you can set the headers in your response to automatically activate the application you want your document to use.

example:
response.setContentType("text/csv");
response.setHeader("content-disposition", "attachment; filename=\""
+ fileName + "\"");
 
Don't get me started about those stupid light bulbs.
 
subject: How to easily write a text file with beautiful format
 
Similar Threads
IO streams
How to store arraylist in xml file
Coversion of ResultSet
Text file xls to Binary format xls in Java.
How to change font of String?