Sie benötigen javax.microedition.io.file.FileConnection
Get Stammordner:
try {
Enumeration roots = FileSystemRegistry.listRoots();
while(roots.hasMoreElements()) {
System.out.println("Root: file:///"+(String)roots.nextElement());
}
} catch(Exception e) {
}
Schreib
public void write(String root) {
FileConnection fc = null;
String fName = "test.txt";
try {
fc = (FileConnection) Connector.open(root + fName, Connector.READ_WRITE);
if(!fc.exists()) {
fc.create();
}
DataOutputStream dos = fc.openDataOutputStream();
dos.writeUTF("test-test");
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
fc.close();
} catch (IOException e) { }
}
}
lesen von Datei Datei
public void read(String root) {
FileConnection fc = null;
try {
fc= (FileConnection) Connector.open(root + "test.txt", Connector.READ);
DataInputStream dis = fc.openDataInputStream();
String data = dis.readUTF();
System.out.println(data);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
fc.close();
} catch (IOException e) { }
}
}
Hallo oxigen, Hier, wo ich den Text Dateinamen nennen? bitte führen Sie mich – Saravanan
kleine Probe hinzugefügt – oxigen
danke ich werde es überprüfen und lassen Sie mich wissen, meine Antwort ... Vielen Dank ... – Saravanan