[1559] in java-interest
Re: FILE object
daemon@ATHENA.MIT.EDU (Thomas Ball)
Thu Sep 7 19:37:47 1995
Date: Thu, 7 Sep 1995 12:16:09 -0700
From: Thomas.Ball@Eng.Sun.COM (Thomas Ball)
To: n1061925@dodo.fit.qut.edu.au
Cc: java-interest@java.Eng.Sun.COM
(Please stop sending your questions to all three groups, as many people are
subscribed to all of them, and are getting several copies of each question.)
If you are running this from an applet, the applet classloader is blocking
access outside the directory the class was loaded from. That's on purpose.
Here's a test file which demonstrates directory listing. (If it doesn't
compile with the alpha compiler, adjust as needed.) Run it using the java
interpreter, *not* as an applet.
import java.io.File;
import java.io.IOException;
public class test {
public static void main(String argv[]) {
File f = new File("/tmp");
String files[] = null;
try {
files = f.list();
} catch (IOException e) {
System.out.println("Failed listing /tmp: ");
e.printStackTrace();
System.exit(1);
}
System.out.println("Files in /tmp:");
for (int i = 0; i < files.length; i++) {
System.out.println("\t" + files[i]);
}
}
}
Tom
> From daemon@java Wed Sep 6 18:43:12 1995
> To: All Java and Hotjava -- Hotjava Interest <hotjava-interest@java>,
> Java Development <java@java>,
> Java Interest <java-interest@java.Eng.Sun.COM>,
> Java Interest 2 <java-interest@java>
> Subject: FILE object
> Mime-Version: 1.0
> X-Info: To unsubscribe, send 'unsubscribe' to hotjava-interest-request@java.sun.com
>
>
> Does anyone know why the method File.list() doesn't work
> eventhough the file object is a directory ?
>
> File dir = new File("/home/me")
>
> /home/me is a directory where I put my class.
>
>
> @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
> @ @
> @ Richard Wahongan @
> @ @
> @ Bach. of Info. Tech. (Hons) | Phone : 61-7-378 3047 (Home) @
> @ Faculty of Information Techn | 61-41-111 5347 (Home) @
> @ Queensland Uni. of Tech. | Email : n1061925@dodo.fit.qut.edu.au @
> @ Bribane 4001 AUSTRALIA | @
> @ @
> @ WWW : http://student.fit.qut.edu.au/~n1061925/ @
> @ @
> @ " Test Everything. Hold on to the good. " @
> @ @
> @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
>
> -
> Note to Sun employees: this is an EXTERNAL mailing list!
> Info: send 'help' to hotjava-interest-request@java.sun.com
>
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com