Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Write and Read Object to File  RSS feed

 
Lilyana Saputra
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • 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??
 
Scott Selikoff
author
Bartender
Posts: 4087
21
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
Kamesh Loganathan
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • 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.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!