Created
March 24, 2015 11:16
-
-
Save WonderCsabo/7c36e9c233083afd3ded to your computer and use it in GitHub Desktop.
java.io.NotSerializableException example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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