class Mammal implements Serializable
{
int legs = 4;
}
public class ObjectSerial
{
public static void main(String[] args)
{
try
{
FileOutputStream fo = new FileOutputStream("mammal.obj");
ObjectOutputStream oo = new ObjectOutputStream(fo);
Mammal m = new Mammal();
oo.writeObject(m);
oo.close();
}
catch(IOException e){}
What puzzles me is when I want to retrieve the class members on the Server side for example, how would I 'reach' the Serialized object.
try
{
FileInputStream fi = new FileInputStream("mammal.obj");
ObjectInputStream oo = new ObjectInputStream(fi);
Mammal m = (Mammal)oo.readObject();
System.out.println(m.legs);
}
catch(IOException e){}
catch(ClassNotFoundException cnf){}
In other words. In a different program the compiler will tell me that the symbol cannot be found.
Hope this question doesn't sound very ignorant. Just to confirm...how do i access the variables of the Serialized object in a different program.
kind regards

New Topic/Question
Reply



MultiQuote



|