2010-12-21 6 views

Antwort

5

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) { } 
    } 
    } 
+0

Hallo oxigen, Hier, wo ich den Text Dateinamen nennen? bitte führen Sie mich – Saravanan

+0

kleine Probe hinzugefügt – oxigen

+0

danke ich werde es überprüfen und lassen Sie mich wissen, meine Antwort ... Vielen Dank ... – Saravanan

1

Das gleiche verwandte Thema im Nokia Forum diskutiert. Für Ihre Referenz sehen Sie diese link... Es kann Ihnen helfen ... :)

1

Besser können Sie FileConnection verwenden.

FileConnection fc=(FileConnection)Connector.ope(url); 
Verwandte Themen