Java Reference
In-Depth Information
Any attempt to use other means than those four classes to access local files for untrusted appli-
cations is not permitted. Listing 11.3 shows an example of these classes used to obtain files
and then process them.
L ISTING 11.3 The FileContentsExample Class
package com.marinilli.b2.c11;
import com.marinilli.b2.c11.util.*;
import javax.jnlp.*;
import java.io.*;
/**
* Chapter 11
* @author Mauro Marinilli
* @version 1.0
*/
public class FileContentsExample {
public FileContentsExample() {
testRead();
testWrite();
writeAsRAF();
System.exit(0);
}
private void testRead() {
FileContents file = null;
FileOpenService fs =
(FileOpenService)Utilities.getService(“javax.jnlp.FileOpenService”);
if (fs!=null) {
try {
file = fs.openFileDialog(null, null);
} catch (Exception e) {
System.out.println(“openFile: “+e);
}
}
if (file!=null) {
process(file);
readLines(file);
}
System.out.println(“finished.”);
}
private void testWrite() {
System.out.println(“testWrite()”);
FileContents file = null;
FileSaveService fs =
(FileSaveService)Utilities.getService(“javax.jnlp.FileSaveService”);
if (fs!=null) {
Search WWH ::




Custom Search