Use Util.readToString(input) instead,
or use InputStream.read(byte[]) instead of InputStream.read() so that you
read a whole buffer at a time rather than one byte at a time.

Steve

On Fri, Apr 6, 2018 at 4:31 AM, Gareth Murfin <gareth.mur...@gmail.com>
wrote:

> I have a lot of info coming down from a server, im using the following
> method to convert from inputstream to string, but it can take many minutes,
> we have 52,000 records coming down (about 20 meg of text!).. Is there any
> way to optimise this method ?
>
> private String readResponseX(InputStream input, int state)
>     {
>         StringBuffer sb = new StringBuffer();
>         try
>         {
>             int chars, i = 0;
>             _("converting response to string");
>             while ((chars = input.read()) != -1)
>             {
>                 sb.append((char) chars);
>             }
>             _("done.");
>             input.close();//////
>         }
>         catch (Exception e)
>         {
>              _("!!!!!!! WARNING !!!!!!!!!! readResponseX() warning error
> reading input steam!!"+e.getMessage());
>
>         }
>         return sb.toString();
>     }
>
> --
> 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/b01596da-b9ef-4ec5-8540-
> 80d175a706e1%40googlegroups.com
> <https://groups.google.com/d/msgid/codenameone-discussions/b01596da-b9ef-4ec5-8540-80d175a706e1%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> 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/CAGOYrKUpGuXGkKdBRq51%2Bpn8gOfi0dpCTXJAeLX_fJvOnhmNXg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to