Hi, I decided to try and create a uwp version of my codename one app but encountered some errors (which don't occur on simulator or ios or old win pohne builds).
To try and solve the issue I have been opening the codename one generated source code in visual studio and trying to debug - this isn't easy as there actually isn't much source code to debug in as it all seems to be in a libary - and I'm not sure the best way to output info to the console window so currently, as you will see in this example I am using dialogs to output information back to me.
Anyway, this code is very straightforward - create a file and try and read it back. It seems that the path to the file is file:///Local:\testfile.txt - it appears to create both streams (ie no exe and no null) but there is no file created an it cannot read anything back.
It seems pretty basic code but is not working. Any thoughts?
Dialog.show("TEST", "Starting file test", "Ok", null);
String fileName = FileSystemStorage.getInstance().getAppHomePath() + FileSystemStorage.getInstance().getFileSystemSeparator() + "testfile.txt";
Dialog.show("TEST", "Filename is " + fileName, "Ok", null);
try {
OutputStream os = FileSystemStorage.getInstance().openOutputStream(fileName);
if (os != null) {
String testOutput = "I am a test";
Dialog.show("TEST", "outstream open", "Ok", null);
os.write(testOutput.getBytes());
Dialog.show("TEST", "Written", "Ok", null);
os.close();
InputStream is = FileSystemStorage.getInstance().openInputStream(fileName);
if (is != null) {
Dialog.show("TEST", "In stream open", "Ok", null);
Dialog.show("TEST", "Bytes available : " + is.available(), "Ok", null);
byte[] dataIn = new byte[is.available()];
is.read(dataIn);
Dialog.show("TEST", "Read", "Ok", null);
String rec = new String(dataIn);
Dialog.show("TEST", "Received " + rec, "Ok", null);
is.close();
}
}
}
catch (Exception e){
Dialog.show("TEST", "Exe " + e.getMessage(), "Ok", null);
}