473,396 Members | 2,011 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,396 software developers and data experts.

serializing an object

dmjpro
2,476 2GB
this is my code .....

import java.io.*;

class TestSerializeClass implements Serializable
{
public TestSerializeClass()
{
System.out.println("Debasis no argument constructor");
}
private void writeObject(ObjectOutputStream out)
{
System.out.println("Debasis write Object");
}
private void readObject(ObjectInputStream in)
{
System.out.println("Debasis read Object");
}
}

class TestSerialize
{
public static void main(String args[])
{
TestSerializeClass t = new TestSerializeClass();
}
}

when those above two private methods will be called and by whome ...


actually i don't understand why the serialization of an object is necessary ...

plz help me out ....

thanx in advance
Feb 24 '07 #1
5 1270
horace1
1,510 Expert 1GB
Serialization involves saving the current state of an object to a stream and restoring an equivalent object from that stream. For example, saving an object to a file and reading it back later or transmitting an object over a network connection from a client to server, etc. Have a read of these tutorials
http://java.sun.com/developer/technicalArticles/Programming/serialization/
http://www.deitel.com/articles/java_tutorials/20050923/IntroductionToObjectSerialization.html
Feb 24 '07 #2
dmjpro
2,476 2GB
thanx for ur reply ....

i understand but can't i do see the two functions called ....

plz give me some hints so that i can do it myself ...

thanx again .....
Feb 25 '07 #3
abctech
157 100+
thanx for ur reply ....

i understand but can't i do see the two functions called ....

plz give me some hints so that i can do it myself ...

thanx again .....
Hello,

If you are trying to call the two methods [viz,writeObject() and readObject() ] declared in class- 'TestSerializeClass' from within the class- 'TestSerialize' you will get an error, can you think why?

Hint: Look at the access modifiers of those methods.
Feb 25 '07 #4
hirak1984
316 100+
we serialize any object to store it somewhere in the hard disk,and remove fron main memory.

it is important for large programs because it reduces the overheads of main memorythus the application speed increases.
this is the most basic idea,I can give.
the details is quite complex.
Feb 26 '07 #5
r035198x
13,262 8TB
this is my code .....

import java.io.*;

class TestSerializeClass implements Serializable
{
public TestSerializeClass()
{
System.out.println("Debasis no argument constructor");
}
private void writeObject(ObjectOutputStream out)
{
System.out.println("Debasis write Object");
}
private void readObject(ObjectInputStream in)
{
System.out.println("Debasis read Object");
}
}

class TestSerialize
{
public static void main(String args[])
{
TestSerializeClass t = new TestSerializeClass();
}
}

when those above two private methods will be called and by whome ...


actually i don't understand why the serialization of an object is necessary ...

plz help me out ....

thanx in advance
Guys, please let's not forget about code tags when posting our code.
Feb 26 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Ante Smolcic | last post by:
Hi all, I have an ArrayList that contains items of type A. I declared the XmlArrayItem atribute for that type. Now I have an derived type B (from A) also contained in the ArrayList but I get...
1
by: Ivo Bronsveld | last post by:
All, I have quite a challenging task ahead of me. I need to write an object model (for code access) based on a schema, which cannot be made into a dataset because of it's complexity. So I...
6
by: Rein Petersen | last post by:
Hi Folks! Here's a strange behaviour: Without a properties SET accessor (see code below), the property will not serialize. public class myObject {
1
by: Chris | last post by:
I'm having trouble Serializing a System.Data.DataColumn object. When I try to serialize it, I get the following: System.NotSupportedException: Cannot serialize member...
2
by: Tobias Zimmergren | last post by:
Hi, just wondering what serializing really is, and howto use it? Thanks. Tobias __________________________________________________________________ Tobias ICQ#: 55986339 Current ICQ status: +...
4
by: Dave Veeneman | last post by:
When does serializing objects make more sense than persisting them to a database? I'm new to object serialization, and I'm trying to get a feel for when to use it. Here is an example: I'm...
4
by: Jason Shohet | last post by:
We are thinking of serializing an object & passing it toseveral functions on web service. This will happen about 35 times as the page loads. The class has about 20 attributes. We're not sure...
3
by: axr | last post by:
Having trouble with Serilization of objects that contain members which are of type Interface eg public class SomeClass { ISomeInterface1 itf1; ClassType1 ct1; ISomeInterface2 itf2;
4
by: mookid8000 | last post by:
Good day group! I have created a nice filtering plugin system, where all filters derive from a Filter class, and they pass a PictureData object between them. I have a problem though. I am able...
2
by: Charles Law | last post by:
I have a complex object that I am serializing, and I would like to omit elements that have a default value. For example, if I have a class as follows Public Class Test Private m_Name As...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.