aspose file tools*
The moose likes Beginning Java and the fly likes How to print ArrayList values? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to print ArrayList values?" Watch "How to print ArrayList values?" New topic
Author

How to print ArrayList values?

Shans sat
Greenhorn

Joined: Jan 24, 2009
Posts: 12
Dear friends,
I'm having ArrayList collection. That ArrayList contains Employee object. The Employee object contains Id, Name, Dept, DOJ, Address properties.
I have to print this ArrayList in a table format.

Could anyone please tell me how to display the print dialogue box and print the ArrayList values in table format?




Thanks in advance,
Shans
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36478
    
  16
What exactly do you mean by printing? On paper or on the command/terminal window?

What does toString() in Employee return?
Can you write a prettyPrintToString() or even a void prettyPrint() method in the Employee class? Then you could iterate through your List and call a pretty-printing method on each included Object.
Shans sat
Greenhorn

Joined: Jan 24, 2009
Posts: 12
I really mean to printing on a paper.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19541
    
  16

A lazy way is to create a JTable, fill it with your objects, then print that. JTable has some nice methods for printing.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Shans sat
Greenhorn

Joined: Jan 24, 2009
Posts: 12
For that I used print() method to print the table values (on paper).




But, the time taken for displaying print dialouge box so late and printing operation is done very slowly.

Could anyone please tell me is there any better way and fastest way to print the table values?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to print ArrayList values?
 
Similar Threads
Need help: Best possible result after comparing objects
iterating tables
Partitioning a JTable
Using EL to retrive data from Arraylist
Struts handling multiple arraylists