Clean up code in finalize() or finally()?
<p>I had the general view that clean up of resources is done in the <code>finally</code> block,<br>
recently I found this particular code snippet in a class and it was overriding the <code>Object</code> class' <a href="http://docs.oracle.com/javase/6/docs/api/java/lang/Object.html#finalize%28%29" rel="nofollow"><code>finalize()</code></a> method.</p>

<pre><code>protected void finalize() {  
    try {
        In.close(); 
        Out.close();
        socket.close();
    }
    catch (Exception e) {
        //logger code here
    }
}
</code></pre>

<p>Is this a good idea? What are the pros and cons of <code>finalize()</code> over <code>finally</code>?</p>
