I am trying to read contents of images folder which has three differnet images in it. I was able to locate the folder but it is not allowing me to read the contents. IT gives exception saying that file was not found (Access is Denied). I changed access permissions for myself on local system for Java folder in C drive but the issue persists. I read on this question Access is denied java.io.FileNotFoundException, that file name needs to be provided, but the path of that folder already contains file name. What am I doing wrong? I am working on a Maven project if that makes any difference. Any help is appreciated. Thanks.
public void getImagesFolder(){
String fileLoc = this.getClass().getResource(IMAGE_FILE).getPath();
int indexIs =fileLoc.indexOf("images/");
String partialPathOfFileLoc = fileLoc.substring(0, indexIs);
// try
// {
// //bufferedReader = new BufferedReader(new FileReader(partialPathOfFileLoc + IMAGE_FILE_WOSLASH));
// bufferedReader = new BufferedReader(new FileReader(fileLoc));
// while((line = bufferedReader.readLine()) != null){
// String imageName = line;
// System.out.println("Image name is: "+ imageName);
// }
// }
// catch (FileNotFoundException e1)
// {
// e1.printStackTrace();
// }
// catch (IOException e)
// {
//
// e.printStackTrace();
// }
File f = new File(fileLoc);
File[] paths;
paths = f.listFiles();
int filesLength =paths.length;
System.out.println("Files length is: "+ filesLength);
for(File path:paths)
{
// prints file and directory paths
System.out.println(path);
}