Added support for java7 setAttribtues
Converted to use misc IOUtils instead of duplicating code
Improved javadoc