Re: [codenameone-discussions] Re: How to save byte array as a file in android and how to view that file in codenameone?

2018-02-16 Thread kantharao512
Thank you so much shai.. its working now .. 


On Thursday, February 15, 2018 at 10:53:39 AM UTC+5:30, Shai Almog wrote:
>
> You did 99% of the work. You saved the file to the right location now you 
> just need to execute that file:
>
> Display.getInstance().execute(fs.getAppHomePath() + "MyFileName.pdf");
>
>

-- 
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 codenameone-discussions+unsubscr...@googlegroups.com.
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/ae5e9585-17ee-4894-b352-9cde1510d62d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [codenameone-discussions] Re: How to save byte array as a file in android and how to view that file in codenameone?

2018-02-14 Thread Shai Almog
You did 99% of the work. You saved the file to the right location now you 
just need to execute that file:

Display.getInstance().execute(fs.getAppHomePath() + "MyFileName.pdf");

-- 
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 codenameone-discussions+unsubscr...@googlegroups.com.
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/563f0fb3-2992-433c-93bd-e2f90fa71bb9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [codenameone-discussions] Re: How to save byte array as a file in android and how to view that file in codenameone?

2018-02-14 Thread kantharao512
No Steve, i don't want to load resource file,  here i want to load byte 
array(getting from service) as pdf file.

how to load byte array as pdf file? .

On Wednesday, February 14, 2018 at 7:21:55 PM UTC+5:30, Steve Hannah wrote:
>
> If you're loading a resource file from the file system, you'll need to use 
> the Resources.open(InputStream) variant.  (i.e. open an input stream from 
> the file system, and pass that to Resources.open().
>
> Steve
>
> On Wed, Feb 14, 2018 at 3:35 AM,  
> wrote:
>
>> when i tried to call "Display.getInstance().execute()" method it is 
>> asking URL but here i have byte array(byte[]).. 
>> so how can i use "Display.getInstance().execute()" for byte array(byte[]).
>>
>> On Wednesday, February 14, 2018 at 10:58:41 AM UTC+5:30, Shai Almog wrote:
>>>
>>> Why are you calling Resources.open?
>>> Try Display.getInstance().execute().
>>>
>>> Resources.open works with "resource files" not files.
>>>
>> -- 
>> 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 codenameone-discussions+unsubscr...@googlegroups.com 
>> .
>> 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/3c249258-0567-437c-a2ec-010429f9eb5a%40googlegroups.com
>>  
>> 
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Steve Hannah
> Software Developer
> Codename One
> http://www.codenameone.com
>

-- 
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 codenameone-discussions+unsubscr...@googlegroups.com.
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/95e79b21-0621-4b28-b151-9974a87d7f7a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [codenameone-discussions] Re: How to save byte array as a file in android and how to view that file in codenameone?

2018-02-14 Thread Steve Hannah
If you're loading a resource file from the file system, you'll need to use
the Resources.open(InputStream) variant.  (i.e. open an input stream from
the file system, and pass that to Resources.open().

Steve

On Wed, Feb 14, 2018 at 3:35 AM,  wrote:

> when i tried to call "Display.getInstance().execute()" method it is
> asking URL but here i have byte array(byte[])..
> so how can i use "Display.getInstance().execute()" for byte array(byte[]).
>
> On Wednesday, February 14, 2018 at 10:58:41 AM UTC+5:30, Shai Almog wrote:
>>
>> Why are you calling Resources.open?
>> Try Display.getInstance().execute().
>>
>> Resources.open works with "resource files" not files.
>>
> --
> 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 codenameone-discussions+unsubscr...@googlegroups.com.
> 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/3c249258-0567-437c-a2ec-
> 010429f9eb5a%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Steve Hannah
Software Developer
Codename One
http://www.codenameone.com

-- 
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 codenameone-discussions+unsubscr...@googlegroups.com.
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/CAGOYrKVTrjNgqPL7xFGMq_Oz%2BOiarFVXNd1DuFqeoMK6jnQ-FA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [codenameone-discussions] Re: How to save byte array as a file in android and how to view that file in codenameone?

2018-02-14 Thread kantharao512
when i tried to call "Display.getInstance().execute()" method it is asking 
URL but here i have byte array(byte[]).. 
so how can i use "Display.getInstance().execute()" for byte array(byte[]).

On Wednesday, February 14, 2018 at 10:58:41 AM UTC+5:30, Shai Almog wrote:
>
> Why are you calling Resources.open?
> Try Display.getInstance().execute().
>
> Resources.open works with "resource files" not files.
>

-- 
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 codenameone-discussions+unsubscr...@googlegroups.com.
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/3c249258-0567-437c-a2ec-010429f9eb5a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [codenameone-discussions] Re: How to save byte array as a file in android and how to view that file in codenameone?

2018-02-13 Thread Shai Almog
Why are you calling Resources.open?
Try Display.getInstance().execute().

Resources.open works with "resource files" not files.

-- 
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 codenameone-discussions+unsubscr...@googlegroups.com.
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/dc5fc967-545a-4158-bc66-1ada4ede2cb4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [codenameone-discussions] Re: How to save byte array as a file in android and how to view that file in codenameone?

2018-02-13 Thread kantharao512
Sorry for late reply Steve..
here is the full stack trace

Resource not found: 
file:///data/data/com.mypackage.myapp/files/MyFileName.pdf
java.io.IOException: 
file:///data/data/com.mypackage.myapp/files/MyFileName.pdf not found
 at com.codename1.ui.util.Resources.open(Resources.java:740)
 at com.codename1.ui.util.Resources.open(Resources.java:679)
 at 
com.mypackage.myapp.MyFileNameForm$1.actionPerformed(MyFileNameForm.java:158)
 at 
com.codename1.ui.util.EventDispatcher.fireActionEvent(EventDispatcher.java:349)
 at com.codename1.ui.Button.fireActionEvent(Button.java:499)
 at com.codename1.ui.Button.released(Button.java:533)
 at com.codename1.ui.Button.pointerReleased(Button.java:637)
 at com.codename1.ui.Form.pointerReleased(Form.java:2980)
 at com.codename1.ui.Component.pointerReleased(Component.java:4100)
 at com.codename1.ui.Display.handleEvent(Display.java:2061)
 at com.codename1.ui.Display.edtLoopImpl(Display.java:1043)
 at com.codename1.ui.Display.mainEDTLoop(Display.java:961)
 at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120)
 at 
com.codename1.impl.CodenameOneThread$1.run(CodenameOneThread.java:60)
 at java.lang.Thread.run(Thread.java:841)

and i forgot to mention that , while trying to open file using below code 
getting this exception.. 

try {
Resources.open(fs.getAppHomePath() + "MyFileName.pdf");
} catch (IOException e) {
e.printStackTrace();
}


but still don't know it is saving or not..


On Tuesday, February 13, 2018 at 6:04:12 PM UTC+5:30, Steve Hannah wrote:
>
> It is very strange that the IOException is reporting the path with the 
> file:/// prefix.   This should have been stripped by the time it gets 
> there.  Can you post a full stack trace?
>
> On Tue, Feb 13, 2018 at 1:09 AM,  
> wrote:
>
>> Thanks shai for reply.. I have tried "fs.mkdir(fs.getAppHomePath());" 
>> like below but still i'm getting  
>>
>>> java.io.IOException: 
>>> file:///data/data/com.engravsystems.emqim/files//MyFileName.pdf not found ..
>>>
>>
>> here is the code :
>>
>>   FileSystemStorage fs = FileSystemStorage.getInstance();
>>
>> try {
>>
>> if(!fs.exists(fs.getAppHomePath()))
>> fs.mkdir(fs.getAppHomePath());
>>
>> OutputStream os = 
>> fs.openOutputStream(fs.getAppHomePath() + "MyFileName.pdf");
>> 
>> os.write(hrFiles.get(finalI).get("fileData").toString().getBytes());
>> Util.cleanup(os);
>> } catch (IOException e) {
>> e.printStackTrace();
>> }
>>
>>
>>
>>
>> On Tuesday, February 13, 2018 at 10:45:10 AM UTC+5:30, Shai Almog wrote:
>>>
>>> I think your code is correct. I think that app home might not exist 
>>> which seems to me like an omission on our part. 
>>> Try 
>>>
>>> fs.mkdir(fs.getAppHomePath());
>>>
>>> -- 
>> 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 codenameone-discussions+unsubscr...@googlegroups.com 
>> .
>> 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/546eb817-a1d9-486b-a507-28d94a4a1f86%40googlegroups.com
>>  
>> 
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Steve Hannah
> Software Developer
> Codename One
> http://www.codenameone.com
>

-- 
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 codenameone-discussions+unsubscr...@googlegroups.com.
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/64393a3b-a82e-47ab-92bd-00726ecd7e9d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[codenameone-discussions] Re: How to save byte array as a file in android and how to view that file in codenameone?

2018-02-13 Thread kantharao512
Thanks shai for reply.. I have tried "fs.mkdir(fs.getAppHomePath());" like 
below but still i'm getting  

> java.io.IOException: 
> file:///data/data/com.engravsystems.emqim/files//MyFileName.pdf not found ..
>

here is the code :

  FileSystemStorage fs = FileSystemStorage.getInstance();

try {

if(!fs.exists(fs.getAppHomePath()))
fs.mkdir(fs.getAppHomePath());

OutputStream os = 
fs.openOutputStream(fs.getAppHomePath() + "MyFileName.pdf");

os.write(hrFiles.get(finalI).get("fileData").toString().getBytes());
Util.cleanup(os);
} catch (IOException e) {
e.printStackTrace();
}




On Tuesday, February 13, 2018 at 10:45:10 AM UTC+5:30, Shai Almog wrote:
>
> I think your code is correct. I think that app home might not exist which 
> seems to me like an omission on our part. 
> Try 
>
> fs.mkdir(fs.getAppHomePath());
>
>

-- 
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 codenameone-discussions+unsubscr...@googlegroups.com.
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/546eb817-a1d9-486b-a507-28d94a4a1f86%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.