Hello there
I am new to my coding career :) and have been facing a slight problem over here
I want to read a folder\s files and have tried countless ways of accessing the directory but keep getting my code's error message. Please have a look and guide me if possible.
Thanks in advance

import java.io.File;

public class Reader 
	int fileslist[];
	File directoryOfTxts = new File("/Users/admin/Documents/workspace/SearchEngine2/src/inputFiles/");
			System.out.println(directoryOfTxts.getName() + "as provided folder is valid");
			String fileslist[] = directoryOfTxts.list();
			System.out.println("Invalid provided directory");
		for(int counter=0; counter<fileslist.length; counter++)
			System.out.println(counter + "\t" + fileslist[counter]);


1. Your code isn't in a method. Try putting it in a main method.
2. You have the array fileslist declared twice: on lines 6 and 12. Change the declaration on line 6 to

String fileslist[] = null;

and change line 12 to this:

fileslist = directoryOfTxts.list();


thanks for fast reply