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/");
{
if(directoryOfTxts.exists())
{
System.out.println(directoryOfTxts.getName() + "as provided folder is valid");
String fileslist[] = directoryOfTxts.list();
}
else
System.out.println("Invalid provided directory");
System.out.println("Id\tName");
for(int counter=0; counter<fileslist.length; counter++)
{
System.out.println(counter + "\t" + fileslist[counter]);
}
}
}