I am Trying to read all the files in a folder and create an arrary with the data.
I know there may be other topics with this but i am having trouble searching For the answer.
Heres the code i am using
import java.io.File;
public class test3 {
public static void main( String [] args ) {
File actual = new File("."); //replace . with file path
int x = 1;
for( File f : actual.listFiles()){
System.out.println( x + ". " + f.getName() );
x++;
}
}}
Thanks
Here’s an example that shows how to read from a file.
Inside that loop you have to open the file, read its contents, and add it to another array or List. Then you can search through the contents of each one.