• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

File.getPath()

 
selvas kumars
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
selvas kumars
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 401
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you look at the javadoc for File.list?

If this abstract pathname does not denote a directory, then this method returns null.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic