public class NewClass {
static class Serial implements Serializable{
public Integer valor = 5;
public Serial(){
}
}
public static void main(String... a){
try {
FileOutputStream fich = new FileOutputStream("C:/miObj.obj");
ObjectOutputStream obj = new ObjectOutputStream(fich);
Serial s = new Serial();
s.valor = 10;
obj.writeObject(s);
obj.close();
FileInputStream fichIn = new FileInputStream("C:/miObj.obj");
ObjectInputStream objIn = new ObjectInputStream(fichIn);
Serial sIn = (Serial)objIn.readObject();
System.out.println(sIn.valor);
objIn.close();
// BufferedOutputStream out = new BufferedOutputStream(System.out);
// DataOutputStream data = new DataOutputStream(System.out);
// data.writeBytes("hola mundo");
// data.close();
} catch (ClassNotFoundException ex) {
Logger.getLogger(NewClass.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(NewClass.class.getName()).log(Level.SEVERE, null, ex);
}
}
}