final static void showAllFiles(File dir) throws Exception{ File[] fs = dir.listFiles(); for(int i=0; i<fs.length; i++){ if(fs[i].isFile()){ System.out.println(fs[i].getAbsolutePath()); getWidth(fs[i].getAbsolutePath()); }else{ try{ showAllFiles(fs[i]); }catch(Exception e){} } } }