Dear Experts Exchange,
the following code list files in a directory, so if I type "javac ListFiles c:\projects" I see all files and directories in "c:\projects".
package listfiles;
import java.io.*;
public class Main {
public Main() {
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
String dir = args.length > 0 ? args[0]: "."; //pass directory to list or current dir
//Get an array of only text files in the directory.
String[] files = new File(dir).list();
System.out.println("runnin
g my file listing test");
for (int i=0; i<files.length; i++) {
File current = new File(files[i]);
System.out.println(current
.getName()
+", "+
String.valueOf(current.las
tModified(
)));
}
}
--------------------------
------
I get output like
run:
running my file listing test
200300N-1526E.aux, 0
200300N-1526E.tif, 0
atcf, 0
bookstore, 0
--------------------------
----------
----------
----------
----------
----------
--
Questions:
I would like to do the same for a URL, so I type "javac ListUrlFiles
http:\\www.text.com\data"
is see all files in the directory supported by a web server (where
http:\\www.txt.com\data is somethign like /usr/local/apache/htdocs/d
ata).
1) Can someone show me how to do list all files as a function of URL, with say java.net.*.
2) Also, I expected to get a unixtime stamp when calling current.lastModified() but instead getting a "0"