Friday, May 3, 2013

Java 6 file IO - installment 5678657



Primer
The not so standard idiom - see an answer there for varargs close() method. And another answer with useful info.

On closing only the outermost buffer : consider (also a bug) -  I actually commented on this here and here

Comparison of the :

final Resource resource = acquire();
try {
    use(resource);
} finally {
    resource.release();
}
 
pattern (see also other answers there - a wealth of info) to the traditional : 

Resource resource = null;
try { 
    resource = acquire();
    use(resource);
} finally {
    if(resource != null) resource.release();
}

(also in DB code)
And a question concerning multiple wrapped streams
 
Btw At what point does wrapping a FileOutputStream with a BufferedOutputStream makes sense,
in terms of performance? with interesting links to source
 
Advanced
Execute around idiom - Skeet - read in your free time, still escapes me.
class Compensation - well that's a good one ! Unfold the try finally block ! Comments like in the Skeet answer apply.


WIP : 2013.05.25 19.12 UTC

Wednesday, May 1, 2013

Android Sleep - Link collection