• Post Reply Bookmark Topic Watch Topic
  • New Topic

To read list of files from server

 
Yogesh Bompilwar
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Please help me out with some solutions.
One of the application will upload some files to some particular directory on the server.I need to read the list of those uploaded files
from the server.Can anyone provide me with some smaple code on how to read the file names from the server.
Thanking in anticipation.

Regards,
Yogesh
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See:
http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html

The File object has methods that return a list of files (as an array) from a directory.
 
Yogesh Bompilwar
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried in my servlet to read the names of files inside the folder images.
As:-

File file = new File("http://127.0.0.1:2020//pim//images");
System.out.println("file created....."+ file);
System.out.println("file created..file.getPath()"+file.getPath());
System.out.println("is the file directory??? "+file.isDirectory());
System.out.println("file.toURL??? "+file.toURL());

What i got as a output :

file created.....http:\127.0.0.1:2020\pim\images
file created..file.getPath()http:\127.0.0.1:2020\pim\images
is the file directory??? false
file.toURL??? file:/D:/tools/jboss-3.2.5/bin/http:/127.0.0.1:2020/pim/images


The folder/directory "images" does exist on the server.
server is installed locally on D:/tools/jboss-3.2.5.


Thanks
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The File(String) constructor is looking for a path to the file; not a URL.
java.lang.String)" target="_blank" rel="nofollow">http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html#File(java.lang.String)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!