You don't have to call flush for every write.  You don't have to call
flush at all.  You do need to close the output stream, though.

On Apr 28, 9:23 am, Daniel Drozdzewski <[email protected]>
wrote:
> Hitendrasinh,
>
> you have to call FileOutputStream.flush() after every write, but
> before you get there, you have to stop writing 1 integer for every
> buffer read.
>
> In other words you are calling wrong FileOutputStream.write() method.
> You need the one that takes buffer, not a single byte.
>
> Daniel
>
> On Thu, Apr 28, 2011 at 2:29 PM, 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
>
> --
> Daniel Drozdzewski

-- 
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