This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes File.getPath() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "File.getPath()" Watch "File.getPath()" New topic
Author

File.getPath()

selvas kumars
Ranch Hand

Joined: Jan 06, 2001
Posts: 115
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
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
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
Did you look at the javadoc for File.list?

If this abstract pathname does not denote a directory, then this method returns null.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: File.getPath()
 
Similar Threads
Recursive file search
Using a directory inside of a JAR file
Access class files between two jar files
JBoss doesn't recognize referenced project
readme.txt