Java > Other
Serialise object to file
Serialise object to file package com.ack.j2se.io; import java.io.FileOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; public class SerialiseObjectToFile { public static void main( String[] args ) throws IOException { String str = new String( "save me!" ); FileOutputStream fos = new FileOutputStream( "thefile.obj" ); ObjectOutputStream oos = new ObjectOutputStream( fos ); oos.writeObject( str ); oos.close(); } }
Java Codes
Beginners
Core Java
Date Time
Java2D
Java Applets
Java AWT
Mathematics
Networking
Servlets
Session
Sound
Swing
Threads
Util Package
JDBC
Learning
Other
Security
XML