import java.io.*;
import java.util.*;
import java.util.zip.*;
public class FindZeroByteFiles {
public FindZeroByteFiles() {
}
public static void main(String[] args) {
FindZeroByteFiles findZeroByteFiles = new FindZeroByteFiles();
File f1 = new File(args[0]);
traverse(f1);
}
public static void traverse(File f) {
String s1 = f.getAbsolutePath();
if (f.isFile())
{
long i = filesize(s1) ;
if (i==0 ) {
System.out.println(s1);
}
}
if (f.isDirectory()) {
String[] children = f.list();
for (int i=0; i<children.length; i++) {
traverse(new File(f, children[i]));
}
}
}
public static long filesize(String filename) {
long i = 0;
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
File f = new File(filename);
if(f.exists()){
long file_size = f.length();
// System.out.println("Size of the file : " + file_size);
i = file_size;
}
return i;
}
}
Run this program with the following arguments.
java -client -classpath C:\ravi FindZeroByteFiles d:\Test
No comments:
Post a Comment