code refinement in JarUtils and DirUtils with resources