Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2005

Tip: Looking for answers? Try searching our database.

Writing objects to a file

Thread view: 
Marcelo - 19 Oct 2005 18:09 GMT
Hi everybody,

I am searching the web in order to find how to write objects (Vector
objects) inside a file.

However, I don't find anything about it. Do you  a class that can make
this? I just want a name in order to find the information (it's that i
don't know where to search./..)

thanks

Marcelo
Oliver Wong - 19 Oct 2005 18:21 GMT
> Hi everybody,
>
[quoted text clipped - 6 lines]
>
> thanks

   Try searching for "Serialization", "Serializable", "Serialize" and other
varations on the term.

   - Oliver
Monique Y. Mudama - 19 Oct 2005 18:25 GMT
> Hi everybody,
>
[quoted text clipped - 8 lines]
>
> Marcelo

Try searching on the word 'serialize'

Signature

monique

Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html

Steve Horsley - 19 Oct 2005 21:39 GMT
> Hi everybody,
>
[quoted text clipped - 8 lines]
>
> Marcelo

java.io.ObjectOutputStream
java io.ObjectInputStream

Steve
Roedy Green - 19 Oct 2005 23:28 GMT
>I am searching the web in order to find how to write objects (Vector
>objects) inside a file.

The term you are looking for is serialization.

See http://mindprod.com/jgloss/serialization.html

for sample code generated see
http://mindprod.com/applets/fileio.html

and tell it you want to read/write serialised objects.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.

Marcelo - 20 Oct 2005 09:53 GMT
Hello, thanks for helping me.

I have another problem. What should I do in order to remove an Object in
my file? should i copy everything of my file into another file without
the given element and then replace the old file? Is there a another way?

thanks

Marcelo
Thomas Weidenfeller - 20 Oct 2005 11:26 GMT
> I have another problem. What should I do in order to remove an Object in
> my file? should i copy everything of my file into another file without
> the given element and then replace the old file?

Yes.

> Is there a another way?

- Design an own, more flexible file format than just a sequence of
serialized objects, or

- Use a database.

/Thomas
Signature

The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/

Roedy Green - 20 Oct 2005 12:08 GMT
>I have another problem. What should I do in order to remove an Object in
>my file? should i copy everything of my file into another file without
>the given element and then replace the old file? Is there a another way?

You use a database with blobs of serialised objects. The SQL engine
deals with the problem.  You can't do anything other than copy with a
sequential file.

You might consider a RandomAccessFile with variable length records of
serialised groups of objects, but that gets pretty hairy pretty
quickly and is not worth the effort given how many free SQL engine
there are.

See http://mindprod.com/projects/hermitcrab.html
if you get the urge to invent a streamlined wheel.

Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.