Created
June 14, 2018 13:57
-
-
Save conikeec/8994e3ba98897a6c6c5c3a7a0ce603ac to your computer and use it in GitHub Desktop.
This file contains hidden or 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.*; | |
public class Serial | |
{ | |
public static void main(String[] args) | |
{ | |
String name = "Ser"; | |
String filename = "file.bin"; | |
try | |
{ | |
FileOutputStream file = new FileOutputStream(filename); | |
ObjectOutputStream out = new ObjectOutputStream(file); | |
// Serialization of the "name" (String) object | |
// Will be written to "file.bin" | |
out.writeObject(name); | |
out.close(); | |
file.close(); | |
} | |
catch(Exception e) | |
{ | |
System.out.println("Exception: " + e.toString()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment