подскажите почему не работает
package com.javarush.task.task20.task2022;
import java.io.*;
/*
Переопределение сериализации в потоке
*/
public class Solution implements Serializable, AutoCloseable {
private transient FileOutputStream stream;
private String fileName = "fdfer";
public Solution(String fileName) throws FileNotFoundException {
this.stream = new FileOutputStream(fileName);
}
public Solution() {
}
public void writeObject(String string) throws IOException {
stream.write(string.getBytes());
stream.write(string.getBytes());
stream.flush();
}
private void writeObject(ObjectOutputStream out) throws IOException {
out.defaultWriteObject();
out.writeObject(stream);
}
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
in.defaultReadObject();
this.stream = new FileOutputStream(fileName, true);
}
@Override
public void close() throws Exception {
System.out.println("Closing everything!");
stream.close();
}
public static void main(String[] args) throws Exception {
Solution solution = new Solution();
}
}