File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

converting ArrayList to Object

 
charlie mills
Ranch Hand
Posts: 49
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have read in data from a file (which is currently in an arrayList). I need to convert this arrayList into Object (ie. - Object[][] addresses = {{"Hancock", "Bob", "01202719029", "07676101393", "1 Seseme Street, London, AB8 8AE"}}; ) because I then need to display all the data from that file in a table(DefaultTabelModel)

I've got the data in an arraylist at the moment but I'm unsure of how to convert it.
 
Rob Camick
Ranch Hand
Posts: 2476
8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have read in data from a file


Well, don't read it into an ArrayList. Read it into a Vector of Vectors instead, then you can create the JTable or DefaultTableModel directly from the Vector.
 
charlie mills
Ranch Hand
Posts: 49
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Having looked up Vectors in the API, that does seem to make a lot more sense! Thanks

What is the difference between Object and Vector?

On a completely separate note, if I were to write data to the file that I have just read from, can I write the data as a String? (so I would write to the file as a string and read it out as a vector?)
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic