Win a copy of Rust Web Development this week in the Other Languages forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Write and Read Object to File

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have some data that i want to save it into File....

i put them all in my own class and then write them into File using PrintWriter... But i don't know how to read and get them back....

Can you tell me??
or i must save them one by one??
 
author
Posts: 4281
34
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its a good thing someone created the Java Almanac which contains *excellent* examples of basic file reading/writing:

http://javaalmanac.com/egs/java.io/WriteToFile.html

There are others on the site I recommend reviewing.
 
Lilyana Saputra
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry for disturb....

what i want is to read and write a object...
i want to put all my data in one my own class and write them together in files...because data that i want to write.. it is so many and large...

i found that PrintWriter can do it by using method: write(object o);
but i can't found any build-in class that can used to read that object from file...

thx
 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
You have something called as ObjectInputStream, u can read a object using this. The analog for writing is ObjectOutputStream.Hopefully this would help.
reply
    Bookmark Topic Watch Topic
  • New Topic