• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to easily write a text file with beautiful format

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 + "\"");
 
Can you shoot lasers out of your eyes? Don't look at this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic