Archive for File

Read all files in a directory

Posted in Programming with tags , , , on November 17, 2006 by wsjoung

int fileCount = 0;
File dir = new File(inputDirName);
File[] strFilesDirs = dir.listFiles();

if (strFilesDirs == null) {
System.err.println(inputDirName +” is not valid directory name or there is no pdb file”);
System.exit(1);
}
for (int i=0; i
if (strFilesDirs[i].isDirectory()) {
//System.out.println(“Directory: “+strFilesDirs[i]);
} else if (strFilesDirs[i].isFile()) {
//System.out.println(“File: “+strFilesDirs[i]+”(“+strFilesDirs[i].length()+”)”);
fileCount = fileCount + 1;
}
}

beside, there is no such method which is changing directory.

Advertisements