Java Reference
In-Depth Information
Listing 7-4. The LocationStore Implemented with the FCOP
package com.apress.rischpater.weatherwidget;
import javax.microedition.io.*;
import javax.microedition.io.file.*;
import java.io.*;
import java.util.*;
public class LocationStore {
private static final String storeName = "wx";
private static final String fileURLRoot = "file:///";
private static String fileUrl;
Vector locations;
FileConnection fc;
public LocationStore() {
locations = new Vector();
Enumeration em = FileSystemRegistry.listRoots();
if (em.hasMoreElements()) {
fileUrl = fileURLRoot + em.nextElement() + storeName;
}
load();
}
private void open() {
if (fc==null) {
try {
fc = (FileConnection)Connector.open(fileUrl,
Connector.READ_WRITE);
}
catch(Exception ex) {}
}
}
private void close() {
if (fc!=null) {
try {
fc.close();
} catch( Exception ex ) {}
fc = null;
}
}
 
Search WWH ::




Custom Search