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.
Murali Nanchala
Ranch Hand
Joined: Mar 14, 2001
Posts: 74
posted
0
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
selvas kumars
Ranch Hand
Joined: Jan 06, 2001
Posts: 115
posted
0
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??
Dave Landers
Ranch Hand
Joined: Jul 24, 2002
Posts: 401
posted
0
Did you look at the javadoc for File.list?
If this abstract pathname does not denote a directory, then this method returns null.