Tuesday, January 29, 2008

You know when you just think 'Oh FFS'

I've just had one of those moments thanks to an article on Chaotic Java (if you're interested in Java then have a look through the archives as it's all gold). Anyway the article is about Java GC & there was a section about using object reference queues instead of a finalize block (a good idea anyway) and there was a line:

I made NativeImage and Image implement Closeable, a new interface in Java 5 for IO classes that need to be closed.

What?!? There's a ... a ... interface called Closeable. Oh yes there is introduced in Java 1.5 and it's been added to just about every IO class. Wish I had know about that before writing the same try finally block for Readers, Writers, InputStreams & OutputStreams. I know it's a case of 20 lines instead of 3 but it seems annoying. I wonder how many more of these interfaces there are in Java 5 & 6 that could have saved me a few more lines of code. 

Oh well

No comments: