Hi again, On further testing it appears that the available() method on the InputStream was returning zero.
Thanks, Paul On Monday, February 13, 2017 at 12:35:04 PM UTC, [email protected] wrote: > > 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? > > Thanks, Paul > > 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); > } > -- You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. Visit this group at https://groups.google.com/group/codenameone-discussions. To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/2d560dbc-3875-418b-9600-53de9c0fccb9%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
