Skip to content

Instantly share code, notes, and snippets.

@WonderCsabo
Created March 24, 2015 11:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WonderCsabo/7c36e9c233083afd3ded to your computer and use it in GitHub Desktop.
Save WonderCsabo/7c36e9c233083afd3ded to your computer and use it in GitHub Desktop.
java.io.NotSerializableException example
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.Serializable;
class Fragment implements Serializable {
private String data;
private Lambda lambda = new Lambda();
private class Lambda {
}
}
public class Main {
public static void main(String[] args) {
Fragment fragment = new Fragment();
try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("state.dat"));){
oos.writeObject(fragment);
} catch (IOException e) {
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment