could apache.commons.IOUtils provide some useful helper methods here?