473,385 Members | 1,320 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Help with serialization

as part of a project at uni i have been asked to provide object persistance
through files

I have opted for serialization

my question is quite simple

when u use serialization is an object saved to a single file or are more
than one object(s) saved to a single file?

say i have three objects, will they all be saved into one file or will there
be three seperate files each having one object saved into them?

also say i have a superclass implmenting the java.io.Serializable

will all subclasses of that superclass automatically implement the
java.io.Serializable or will i need to make those subclasses implement the
Serializable seperately?

any help would be appreciated

PS -
public class UserData implements java.io.Serializablei understand that
but..public class UserData extends User...how would i implement the
java.io.Serializable in that class? would it be...public class UserData
implements java.io.Serializable extends UserORpublic class UserData extends
User implements java.io.SerializableThanks in advanceChristo
Apr 17 '06 #1
1 3069
Christo wrote:
as part of a project at uni i have been asked to provide object persistance
through files

I have opted for serialization

my question is quite simple

when u use serialization is an object saved to a single file or are more
than one object(s) saved to a single file?

say i have three objects, will they all be saved into one file or will there
be three seperate files each having one object saved into them?

also say i have a superclass implmenting the java.io.Serializable

will all subclasses of that superclass automatically implement the
java.io.Serializable or will i need to make those subclasses implement the
Serializable seperately?

any help would be appreciated

PS -
public class UserData implements java.io.Serializablei understand that
but..public class UserData extends User...how would i implement the
java.io.Serializable in that class? would it be...public class UserData
implements java.io.Serializable extends UserORpublic class UserData extends
User implements java.io.SerializableThanks in advanceChristo


Serialization is about converting objects into Streams of
reconstitutable data. What you do with the stream is up to you. Also,
once a class implements an interface all subclasses automatically
implement it.

Java API Javadocs are your friend:
http://java.sun.com/j2se/1.4.2/docs/...putStream.html

Another thing to look up is the java keyword "transient"
Apr 18 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Wayne Wengert | last post by:
This is my first attempt to re-write an old VB6 application that exported a CSV file to a .NET application that exports an XML file with the equivelent data. I have limited understanding of OO...
4
by: Jeff T. | last post by:
Hello, I have an existing set of C# classes that encapsulate our application data. They are in a heirachy with each subclass defining more specific types of data. I would like to serialize these...
1
by: Opa | last post by:
Hi I'm having problem serialization an object instance which contains a public property on the object type My object hierarchy is many levels deep, so for simplicty I created to following which...
2
by: Tiraman :-\) | last post by:
Hi Everyone, i have the following problem in my client-server Application My server take array and serialize it into the memorystream Dim ns As NetworkStream = client.GetStream() Dim writer...
4
by: Chris | last post by:
I don't know if it's me or .net is just getting more complicated. I am trying to call a sp and pass a parameter and return the data using VB2005. First I couldn't find any docs with samples. Second...
0
by: Jeremy Chapman | last post by:
I'm building a class with xml serialization attrbutes. Below I've included the class and the xml it serializes to. It pretty much matches what I want except for the Message property of the...
3
by: namewitheldbyrequest | last post by:
"The XML element 'EnableTheming' from namespace 'http://tempuri.org/' is already present in the current scope" I created a Web Service: I imported System.Data.SqlClient so I could access SQL...
13
by: Marc | last post by:
The first part of the below writes the name and location of all buttons on a from to a text file. The second part reads that information back in and recreates the buttons. My problem is reading...
1
by: kikisan | last post by:
I am developing a windows service which utilizes the following classes: interface IPersistable; abstract class PersistableObject : IPersistable;
3
by: Rene | last post by:
OK, I give up, the msdn help for custom serialization: http://msdn2.microsoft.com/en-us/library/ty01x675(VS.90).aspx Hs the following paragraph on it: ----- In addition, you should not use...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.