proper exception handling and resource management (java 6)