FileConnection fconn = null;
try {
String path = System.getProperty("fileconn.dir.photos");
//#debug error
System.out.println("Photo dir: " + path);
String fullPath = null, fileName = "huypv.txt";
if( path.endsWith("/") )
fullPath = path + fileName;
else
fullPath = path + "/" + fileName;
//#debug error
System.out.println("Fullpath: " + fullPath);
fconn = (FileConnection) Connector.open(fullPath, Connector.READ_WRITE);
byte data[] = "Bay gio la ".concat(String.valueOf(System.currentTimeMillis())).getBytes();
if (!fconn.exists()) {
fconn.create();
} else {
fconn.truncate(0);
}
OutputStream ops = fconn.openOutputStream();
ops.write(data);
ops.close();
fconn.close();
} catch (Exception e) {
//#debug error
System.out.println("Exception: " + e.getMessage());
}
Form frm = new Form("Form");
frm.addCommand(new Command("Exit", Command.EXIT, 1));
Display.getDisplay(this).setCurrent(frm);
frm.setCommandListener(new CommandListener() {
public void commandAction(Command cmnd, Displayable dsplbl) {
notifyDestroyed();
}
});
if (true) return;
Title:
Test FileConnection API on real device
Description:
FileConnection fconn = null; try { String path = System.getProperty("fileconn.dir.photos"); //#debug error ...
...
Rating:
4