Reputation: 155
I am getting response from service as byte array(byte[]). in my app i want to show the file(pdf/doc) in app itself. is it possible? is there any way to save and view the file in codenameone?
Upvotes: 1
Views: 313
Reputation: 1907
Please try this code
String newString = String(byte[] bytes);
For PDF you need to create a file and open it using the native viewer:
FileSystemStorage fs = FileSystemStorage.getInstance();
String fileName = fs.getAppHomePath() + "myPDF.pdf";
try(OutputStream os = fs.openOutputStream(fileName)) {
os.write(myByteArrayData);
}
Display.getInstance().execute(fileName);
Upvotes: 2