Hi all, I am trying to read a list of files from the filesystem inside a method of class say A1. This objectA1 method is called by a bean method. It is not able to list the files, but able to print the path.Is that inside a bean we can't acess the file system?? code snippet is below.
final File path = new File(strFileName); System.out.println("path is "+path.getPath()); String list = strImgList = path.list(); list value is null. Thanks, silva.
Joined: Mar 14, 2001
If 'path is of type File then can you compile this line: String list = strImgList = path.list(); 'cause the list() method returns an array of Strings. Do you want to post the complete code, atleast the complete method if your Class is large. Murali
"It is almost always answered in the API" - Murali Nanchala
Joined: Jan 06, 2001
Thanks murali. sorry, my code is like the below. strFileName holds the file path. This method is executed on unix machine. final File path = new File(strFileName); System.out.println("path is "+path.getPath()); String strImgList = path.list(); strImgList value is null. what might be the reason for this??
Joined: Jul 24, 2002
Did you look at the javadoc for File.list?
If this abstract pathname does not denote a directory, then this method returns null.