728x90 AdSpace

Trending

IO Streams in java

Saving Objects

 Object have state and behavior. Behaviour lives in the class, but state live with in each indivijual Object.
If your data will be used by only the java program that generated it, then use Serialization. 
 Write a file that holds serialized
If your data is used by other program then write a plain text file.
write a text file which delimiters that other programs can prase.
Files are nothing but collection of files.
In this post we are going to deal with the text files.
Writing text data into a file
 it is similar to writing an object, except you write a string instead of object, and FileWriter instead of FileOutputStream.
FileWriter fw=new FileWriter("filename");
BufferedWriter bw=new BufferedWriter();
w.write("string");
w.close();
Reading a text data from the file
FileReader rw=new FileReader("filename");
BufferedReader bw=new BufferedReader();
String s=w.readLine();
w.close();


Comment box is waiting for your opinion............!

IO Streams in java Reviewed by Unknown on 09:53 Rating: 5 Saving Objects  Object have state and behavior. Behaviour lives in the class, but state live with in each indivijual Object. If your dat...

No comments: