The Student Room Group

Recursive Methods <in Java>

hello, can you help me,

I have code to scan recursivily through files on a computer

But I need to be able to retrieve and put files of the same size (byte length) in any type of collection (array i think) to process them further (well to check their equality)



import java.io.*;
import java.util.*;

public class RecursiveClass {
public static void main(String[] args) {
for(File file : File.listRoots()){
search(file);
}
}



public static void search(File f) {
if ( !f.exists() ) return;
String name = f.getName();
System.out.println(name);
if ( f.isDirectory() ) {
File[] files = f.listFiles();
if (files != null) {
for( int i = 0 ; i < files.length; i++ ) {
search( files );
}
}
}

}




}



any help i am strugling!

Latest

Trending

Trending