2010-12-14 53 views

Répondre

0

Vous pouvez utiliser ce code pour écrire les données dans un fichier.

private void writeTextFile(String fName, String text) { 
    DataOutputStream dos = null; 
    FileConnection fconn = null; 
    try { 
     fconn = (FileConnection) Connector.open(fName, Connector.READ_WRITE); 
     if (!fconn.exists()) 
      fconn.create(); 
     dos = fconn.openDataOutputStream(); 
     dos.write(text.getBytes()); 
    } catch (IOException e) { 
     System.out.println(e.getMessage()); 
    } finally { 
     try { 
      if (dos != null) 
      dos.close(); 
      if (fconn != null) 
       fconn.close(); 
     } catch (IOException e) { 
      System.out.println(e.getMessage()); 
     } 
    } 
}