M
moonhk
import java.util.Date;
public class OWRS {
public String S1;
public Date currDate ;
}
import java.io.*;
import java.util.Date;
import java.text.*;
public class OWS {
public static void main(String[] args) throws IOException {
FileOutputStream out = new FileOutputStream("theTime");
ObjectOutputStream s = new ObjectOutputStream(out);
System.out.println("Write Object to file theTime");
OWRS me = new OWRS();
me.S1 = "Today";
me.currDate = new Date();
//s.writeObject("Today");
//s.writeObject(new Date());
s.writeObject(me);
s.flush();
}
}
Runtime error
D:\Example\javaux\IO>java OWS
Write Object to file theTime
Exception in thread "main" java.io.NotSerializableException: OWRS
at
java.ibjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
at
java.ibjectOutputStream.writeObject(ObjectOutputStream.java:302)
at OWS.main(OWS.java:25)
D:\Example\javaux\IO>
public class OWRS {
public String S1;
public Date currDate ;
}
import java.io.*;
import java.util.Date;
import java.text.*;
public class OWS {
public static void main(String[] args) throws IOException {
FileOutputStream out = new FileOutputStream("theTime");
ObjectOutputStream s = new ObjectOutputStream(out);
System.out.println("Write Object to file theTime");
OWRS me = new OWRS();
me.S1 = "Today";
me.currDate = new Date();
//s.writeObject("Today");
//s.writeObject(new Date());
s.writeObject(me);
s.flush();
}
}
Runtime error
D:\Example\javaux\IO>java OWS
Write Object to file theTime
Exception in thread "main" java.io.NotSerializableException: OWRS
at
java.ibjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
at
java.ibjectOutputStream.writeObject(ObjectOutputStream.java:302)
at OWS.main(OWS.java:25)
D:\Example\javaux\IO>