Adapting code to commons-io lib