Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Java Basics
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 Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old November 4th, 2009, 06:45 AM
Authorized User
Join Date: Jan 2009
Posts: 10
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;



// 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




catch ( IOException e )


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



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 10:36 AM
Multiple views of single table jatatman ASP.NET 3.5 Basics 1 June 2nd, 2008 01:34 AM
Multiple domains on a single IP qazi_nomi Classic ASP Basics 24 September 22nd, 2004 06:41 PM
Single or Multiple application. Gibs_poovath General .NET 7 May 25th, 2004 07:54 AM
Multiple file input single file output.... jdm_mboy Biztalk 1 July 2nd, 2003 03:35 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.