• 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

Using ObjectOutputStream....but want to switch

 
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm currently using an ObjectOutputStream to write the contents of my vector to text file. The vector contains objects created from a class hierarchy which implements serializable. Since serializable objects create a binary-format file (which is unreadable), how can I go about using PrintWriter to write out all the objects my vector contains? I'm completely new to all of this, but If i could write a neatly formatted text file, where each object was written on a new line, that would be awesome. Could someone show me how?

 
Ranch Hand
Posts: 1296
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is an example using a PrintWriter to write a Collection:



When run this code will create a file called dogs.txt with the following contents:

[ March 05, 2007: Message edited by: Garrett Rowe ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic