p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > Java > Java and JDK > Java Basics
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Java Basics General beginning Java language questions that don't fit in one of the more specific forums. Please specify what version.

Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java Basics section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 4th, 2009, 06:45 AM
Registered User
Points: 29, Level: 1
Points: 29, Level: 1 Points: 29, Level: 1 Points: 29, Level: 1
Activity: 5%
Activity: 5% Activity: 5% Activity: 5%
 
Join Date: Jan 2009
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Write multiple object in a single file

Hello Everybody
How are you all? I have some little problem. But there is no suitable solution in the internet. My problem:

I want to write multiple object in a single file. But i cant. I can write a single object in the file using writeObject() method. Can any one help me to give a better solution? For your kind consideration my code given below:

public void writeObject ( String fullFilename, Object object )
{

// create the object file

File objectFile = new File(fullFilename);

// generic stream to the file

FileOutputStream outStream;

// stream for objects to the file

ObjectOutputStream objStream;



try

{

// setup a stream to a physical file on the filesystem

outStream = new FileOutputStream ( objectFile );



// attach a stream capable of writing objects to the stream that

// is connected to the file

objStream = new ObjectOutputStream ( outStream );

// write object to file

objStream.writeObject( object );



// close down the streams

objStream.close();

outStream.close();

}

catch ( IOException e )

{

logger.error( "could not write object to file ",e);

}

}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Serializing needs File object on Read, not on Write jcotton BOOK: Beginning Java 2 0 May 7th, 2009 11:36 AM
Multiple views of single table jatatman ASP.NET 3.5 Basics 1 June 2nd, 2008 02:34 AM
Multiple domains on a single IP qazi_nomi Classic ASP Basics 24 September 22nd, 2004 07:41 PM
Single or Multiple application. Gibs_poovath General .NET 7 May 25th, 2004 08:54 AM
Multiple file input single file output.... jdm_mboy Biztalk 1 July 2nd, 2003 04:35 AM



All times are GMT -4. The time now is 05:06 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc