I am trying to extend java.io.BufferedWriter to make it Serializable . I tried just extending the BufferedWriter and implementing the Serializable interface. It has two constructors, so the code is as follows.
class SerializableBufferedWriter extends BufferedWriter implements Serializable{ private static final long serialVersionUID = 1625952307886764541L; public SerializableBufferedWriter(OutputStreamWriter osw, int size){ super(osw, size); } public SerializableBufferedWriter(OutputStreamWriter osw){ super(osw); } }
But at runtime, I get an invalid constructor exception. After reading here, for a class to implement Serializable , for it, the non-serializable superclass must first have a constructor with no arguments. So, how do I add a class between a constructor with no arguments that extends BufferedWriter and extends to SerializableBufferWriter ?
Any help is appreciated
source share