//Ecriture dans un fichier
private void ecriture(String message){
System.getProperty("microedition.io.file.FileConnection.version");
try
{ System.out.println("test1");
FileConnection connection = (FileConnection)
Connector.open("file:///SD Card/texte.cvs", Connector.READ_WRITE );
//Connector.open("file:///root1/texte.cvs", Connector.READ_WRITE );
OutputStream out = connection.openOutputStream(connection.fileSize());
PrintStream output = new PrintStream( out );
output.println( message);
out.close();
connection.close();
}
catch( ConnectionNotFoundException error )
{System.out.println("fichier non trouvé");
Alert alert = new Alert(
"Error", "Cannot access file.", null, null);
alert.setTimeout(Alert.FOREVER);
alert.setType(AlertType.ERROR);
_display.setCurrent(alert);
}
catch( IOException error )
{System.out.println("fichier non trouvé2");
Alert alert = new Alert("Error", error.toString(), null, null);
alert.setTimeout(Alert.FOREVER);
alert.setType(AlertType.ERROR);
_display.setCurrent(alert);
}
Partager