Methods Summary |
---|
public static java.lang.String | getFilename()Gets the filename to use as a composition of user home and demo.dat.
String filename =
System.getProperty("user.home") + System.getProperty("file.separator")
+ "demo.dat";
return filename;
|
public static final void | main(java.lang.String[] args)Main Demo Method.
try {
writeCountry4();
readCountry4();
System.out.println();
writeCountry5();
readCountry5();
System.out.println();
writeCountry6();
readCountry6();
} catch (final FileNotFoundException ex) {
throw new RuntimeException(ex);
} catch (final IOException ex) {
throw new RuntimeException(ex);
} catch (final ClassNotFoundException ex) {
throw new RuntimeException(ex);
}
|
public static void | readCountry4()Reads a Country4 from a file.
// --
System.out.println("Country4 in VM");
System.out.println("Type = " + Country4.GERMANY.getClass());
System.out.println("Name = " + Country4.GERMANY.getName());
System.out.println("Hashcode = " + Country4.GERMANY.hashCode());
// --
FileInputStream fis = new FileInputStream(getFilename());
ObjectInputStream ois = new ObjectInputStream(fis);
Country4 inCountry = (Country4)ois.readObject();
// --
System.out.println("----------------");
System.out.println("Country4 read in");
System.out.println("Type = " + inCountry.getClass());
System.out.println("Name = " + inCountry.getName());
System.out.println("Hashcode = " + inCountry.hashCode());
// --
System.out.println("----------------");
System.out.println("Identical = " + (inCountry == Country4.GERMANY));
|
public static void | readCountry5()Reads a Country5 from a file.
// --
System.out.println("Country5 in VM");
System.out.println("Type = " + Country5.GERMANY.getClass());
System.out.println("Name = " + Country5.GERMANY.getName());
System.out.println("Hashcode = " + Country5.GERMANY.hashCode());
// --
FileInputStream fis = new FileInputStream(getFilename());
ObjectInputStream ois = new ObjectInputStream(fis);
Country5 inCountry = (Country5)ois.readObject();
// --
System.out.println("----------------");
System.out.println("Country5 read in");
System.out.println("Type = " + inCountry.getClass());
System.out.println("Name = " + inCountry.getName());
System.out.println("Hashcode = " + inCountry.hashCode());
// --
System.out.println("----------------");
System.out.println("Identical = " + (inCountry == Country5.GERMANY));
|
public static void | readCountry6()Reads a Country6 from a file.
// --
System.out.println("Country6 in VM");
System.out.println("Type = " + Country6.GERMANY.getClass());
System.out.println("Name = " + Country6.GERMANY.getName());
System.out.println("Hashcode = " + Country6.GERMANY.hashCode());
// --
FileInputStream fis = new FileInputStream(getFilename());
ObjectInputStream ois = new ObjectInputStream(fis);
Country6 inCountry = (Country6)ois.readObject();
// --
System.out.println("----------------");
System.out.println("Country6 read in");
System.out.println("Type = " + inCountry.getClass());
System.out.println("Name = " + inCountry.getName());
System.out.println("Hashcode = " + inCountry.hashCode());
// --
System.out.println("----------------");
System.out.println("Identical = " + (inCountry == Country6.GERMANY));
|
public static void | writeCountry4()Writes an Country4 to a file.
FileOutputStream fos = new FileOutputStream(getFilename());
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(Country4.GERMANY);
|
public static void | writeCountry5()Writes an Country5 to a file.
FileOutputStream fos = new FileOutputStream(getFilename());
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(Country5.GERMANY);
|
public static void | writeCountry6()Writes an Country5 to a file.
FileOutputStream fos = new FileOutputStream(getFilename());
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(Country6.GERMANY);
|