Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Applet and reading Files?

Status
Not open for further replies.

piranha999

Technical User
Oct 8, 2001
8
0
0
AT
Could anybody please tell me how it is possible to read files with an Applet without Security conflicts.

My class looks like this

import java.io.*;
import java.util.*;
import java.net.URL;

public class ReadFile {

private BufferedReader in;
//public String path = "***";
//public String file = "***.***";

public ReadFile() {

try {
in = new BufferedReader(new FileReader(new File(ReadFile.class.getResource("***.***").getPath())));
}
catch (IOException e) {}
}

public String readLine() {


String s = null;
try {
s = in.readLine();

}
catch (IOException e) {}
return s;
}

public void close() {
try {
in.close();
}
catch (IOException e) {}
}


public Vector read() {
Vector v = new Vector();
for (String helper = readLine(); helper != null )
{
v.addElement(helper);
helper = readLine();
}
close();
return v;
}


}
 
Applets are deemed to be untrusted and as such there are certain restrictions in their use concerning the file system. They are not allowed to:
1. Read/write to the local file system
2. Delete files on the local file system
3. Rename files on the local file system
4. Create directories
5. Read directories
6. Check that a file exists
7. Get file properties such as date created, size etc.

Some browsers, applet viewers may relax some of these restrictions. The applet viewer allows an adminstrator to define specific directories for reading/writing. Obviously this is fairly limiting.

The only way to do this for browser contained applets is to attach a digital signature to a jar file. These is a little long winded to state here but information can be found :
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top