Free Jobs

Java Forums: Core Java (15) J2EE (3) EJB (5) Servlet (3) JDBC (6) Hibernate (2) Struts (1) Swing (1) Oracle (7) JSP (4) Other (10)

Topic: How to write and read a java object to a File Stream

To get the Posted Questions details daily in your mail Click Here

Share this Post on Facebook/Twitter/Orkut Bookmark and Share

User: mohit555 Post Date: 10 Apr 2011 10:55

In this post I will be giving you syntax to read write java object to a file stream
for distributed programming

Main Content:

How to write a java object to a FileOutPutStream

You may need to write a java object to a file FileOutPutStream

for distributed programming.

The syntax is as below:

FileOutPutStream MyFileStream = new FileOutPutStream("temp");

ObjectOutPutStream MyOutput = new ObjectOutPutStream(MyFileStream);



How to read a java object from a FileInputStream

You may need to read a java object using FileInputStream

for distributed programming.

The syntax is as below:

FileInputStream MyFileStream = new FileInputStream(filename);

ObjectInPutStream MyInput = new ObjectInPutStream(MyFileStream);

Object obj = MyInput.readObject();


Thus we can serialize and construct the object again from file stream

About Writer:
Hi All,I am Java Developer From Bangalore

Writer's Link:

Writer's Email:

Post Comment

Similar Articles Top ArticlesLatest Articles Other Articles by this Author Copyright © 2009-2011 | All Rights Reserved
All content of this website is protected by copyright laws and should not be reproduced in any form or by any means without written permission
(Best viewed in IE 8.0+ or Firefox 3.0+ at resolution of 1024 * 768 or higher)