Reputation: 351
I cannot find any mention of writing strings to a text file in Codename One. I need to create and maintain a "directory" of saved image groups so I can retrieve the name of the group and then retrieve the images by their saved name in ImageViewer. Has anyone developed an imitation of the Java FileWriter?
Upvotes: 1
Views: 73
Reputation: 52770
Codename One has a Writer
class but not a FileWriter
since the file system is a bit different from the one on the OS.
You can just use FileSystemStorage
or Storage
to write a text file just like you can in Java SE using OutputStream
or Writer
. E.g.:
FileSystemStorage fs = FileSystemStorage.getInstance();
String filePath = fs.getAppHomePath() + "my_file.txt";
try(Writer w = new OutputStreamWriter(fs.openOutputStream(filePath))) {
w.write("This is the text in the file");
} catch(Exception e) {
Log.p("Error " + e);
}
Upvotes: 2