I am trying to get the names of all the directories and files that inside the tpo
directory on some server but as I run the following code:
public static void main(String args[]) {
try {
File file = new File(new URI("http://xxx/tpo/"));
String list[] = file.list();
for(String name : list) {
System.out.println(name);
}
}catch(Exception exc) {
exc.printStackTrace();
}
}
I get the following exception :
java.lang.IllegalArgumentException: URI scheme is not "file"
at java.io.File.<init>(File.java:366)
at hack.List.main(List.java:17)
Why is that ? How do I get the file names and the names of the directories inside the tpo
directory.
You can't. The webserver gives you an html page that contains a list of files if he wants to. If he doesn't, then you have to login via FTP into the server. The error message:
java.lang.IllegalArgumentException: URI scheme is not "file"
Says exactly what is wrong. java.io.File
is meant for offline files on your local harddrives/usb devices.
Collected from the Internet
Please contact debug[email protected] to delete if infringement.
Comments