Don't forget to close the output stream.

On Apr 28, 11:29 pm, Vishwas Undre <[email protected]> wrote:
> Hi,
>
> use next code
>
>  FileOutputStream fileOutput = new FileOutputStream(filepath);
>
>  InputStream inputStream = urlConnection.getInputStream();
>
>  int[] key = {123,456};
>  int totalRead = 0;
> int read = 0;
> do{
>        read =  inputStream.read(buffer);
>
>        if(read==0)
>                 break;                                                        
>                   
>        fileOutput.write(buffer,0,read);
>         totalRead+=read;
>
> }while (true);
>
> On 28/04/2011, Hitendrasinh Gohil <[email protected]> wrote:
>
>
>
> > hi,
>
> > Below is my code that i am writing the file.
>
> > FileOutputStream fileOutput = new FileOutputStream(filepath);
>
> > InputStream inputStream = urlConnection.getInputStream();
>
> > int[] key = {123,456};
> >                                                                             
> >        int totalRead = 0;
> >                                                                             
> >        int read = 0;
>
> >                                                                             
> >        do
> >                                                                             
> >        {
> >                                                                             
> >                read =  inputStream.read(buffer);
>
> >                                                                             
> >                fileOutput.write(read ^ key[totalRead % (key.length-1)]);
>
> >                                                                             
> >                totalRead+=read;
> > //totalRead++;
>
> >                                                                             
> >        }while (read>0);
>
> > i am able to write only some kbs from the inputstream.
>
> > If i write the file byte by byte than it works but it takes to much
> > time.
> > like
> > read= inputStream.read();
> > totalRead++;
>
> > can anyone help me what is the problem with above code?
>
> > regards,
> > hitendrasinh gohil
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en
>
> --
>
> [image: vishwas.gif]
>
> * Vishwas Undre  *
> (+919970502481)

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to