Can i write oblects in java into file and retrieve the same?? In c++ we ise wrie function.. can i realize this in java?
In C++ we may use
fin.write((char*)&object,sizeof(classname));
how can i realize this in java.?
You can use an ObjectOutputStream to serialize objects to a file (or any other output stream) and ObjectInputStream to read them back in. Objects need to implement the Serializable interface to be useful with these classes. Not all objects can be serialized. (For example, it wouldn't make sense or be very useful to serialize a socket.)