サンプル
protected void finalize() throws Throwable {
try {
OutputStream stream = getOutputStream();
stream.flush();
stream.close();
}
catch (IOException exc) {
LogUtility.log(exc);
}
finally {
super .finalize();
}
}

private OutputStream getOutputStream() {
return _stream;
}

private transient OutputStream _stream;
ソリューション
finalize() メソッドの代わりに、クリーンアップ・メソッドを明示的に呼び出して使用します。
public void free() {
try {
OutputStream stream = getOutputStream();
stream.flush();
stream.close();
}
catch (IOException exc) {
LogUtility.log(exc);
}
}

private OutputStream getOutputStream() {
return _stream;
}

private transient OutputStream _stream;