Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: fout should be declared before the try block so that it could be referenced in the finally block

...

Code Block
bgColor#ccccff
public class Point {
 private transient double x; // declared transient
 private transient double y; // declared transient

 public Point(double x, double y) {
  this.x = x;
  this.y = y;
 }

 public Point() {
   // no-argument constructor
 }
}

public class Coordinates extends Point implements Serializable {
  public static void main(String[] args) {
    FileOutputStream fout = null;
    try {
      Point p = new Point(5,2);
      FileOutputStream fout = new FileOutputStream("point.ser");
      ObjectOutputStream oout = new ObjectOutputStream(fout);
      oout.writeObject(p);
      oout.close();
    } catch (Exception e) {
      // Forward to handler
    } finally {
      if (fout != null) {
        try {
          fout.close();
        } catch (IOException x) {
          // handle error
        }
      }
    }
  }
}

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="92e09f7f30bf8ad6-92f4c214-4212482a-9d4d9bb4-e4e11fa3c120b33ecb97a908"><ac:plain-text-body><![CDATA[

[[Bloch 2005

AA. References#Bloch 05]]

Puzzle 83. Dyslexic monotheism

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="46f015d2bbc8e9f0-5bf0e9e3-4ca84618-8d2bb3d6-c39ffada17b0389eb1cb3f6a"><ac:plain-text-body><![CDATA[

[[Bloch 2001

AA. References#Bloch 01]]

Item 1. Enforce the singleton property with a private constructor

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="8681258d3a539168-6aa3eed4-4d504aae-a299b5a9-c5a377454edd04f12bf998e9"><ac:plain-text-body><![CDATA[

[[Greanier 2000

AA. References#Greanier 00]]

[Discover the Secrets of the Java Serialization API

http://java.sun.com/developer/technicalArticles/Programming/serialization/]

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="d5c0dbdd9addf8c2-6a0d560d-433b4411-b5d2940d-76b957d0b88daf31c453110f"><ac:plain-text-body><![CDATA[

[[Harold 1999

AA. References#Harold 99]]

 

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="64073d6c10fe3b7f-db7e4632-45ff4766-ad81b40b-9d4a7ac2e973b8e0af6506a2"><ac:plain-text-body><![CDATA[

[[JLS 2005

AA. References#JLS 05]]

[Transient Modifier

http://java.sun.com/docs/books/jls/third_edition/html/classes.html#37020]

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="f3366d03719d805f-03dc8540-40a44527-97649561-141d7fc720a82ce3377dcb9e"><ac:plain-text-body><![CDATA[

[[Long 2005

AA. References#Long 05]]

Section 2.4, Serialization

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="e6a2a0aeba5a00c5-c2799ac6-4f9144bf-91e793fb-459be67b2e8939f288f3eb8f"><ac:plain-text-body><![CDATA[

[[Sun 2006

AA. References#Sun 06]]

Serialization Specification, A.4, Preventing Serialization of Sensitive Data

]]></ac:plain-text-body></ac:structured-macro>

...