If I write my code like this, it gives an error "File not found access denied ......"
public class ImplRegistration implements IRegistration {
@Override
public boolean newRegistration(Registration_BE reg_be) {
FileOutputStream fos = new FileOutputStream("serial.ser");
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(reg_be);
}
}
For security reasons, I changed the fourth line of the code to this:
FileOutputStream fos = new FileOutputStream("f://serial.ser");
But then it showed the exception java.io.NotSerializableException: java.io.ByteArrayInputStream.
How can I serialize the object?
Serializableinterface. Also, it would be good if you share the problematic code and post the stacktrace instead of the error message.C:/will always give you access denied. Note that in Windows, the path should be likef:\\\\some\\path, or again, use/some/path.Registration_BEclass includes a non-transientByteArrayInputStreamfield. This is not serializable, so the entire class is not serializable.