Skip to content

Instantly share code, notes, and snippets.

@conikeec
Created June 14, 2018 13:57
Show Gist options
  • Save conikeec/8994e3ba98897a6c6c5c3a7a0ce603ac to your computer and use it in GitHub Desktop.
Save conikeec/8994e3ba98897a6c6c5c3a7a0ce603ac to your computer and use it in GitHub Desktop.
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