Wednesday, April 13, 2011

[android-developers] Re: missing last 7 or 8 bytes while writing to file from inputstream?

You need to call os.close(), at least. os.close() should call
os.flush(). If you don't close or flush, then some of the last bytes
written may remain in the output stream's buffer.

OutputStream.flush() doesn't do anything because it doesn't buffer
anything.

On Apr 13, 12:25 am, Hitendrasinh Gohil
<hitendra.virtuei...@gmail.com> wrote:
> hi,
>
> i am just writing one file from other file,but last 7 or 8 bytes are
> missing.i am using below code to write the file.
>
> buf= new byte[4096];
>  int numRead = 0;
>             while ((numRead = is.read(buf))>0) {
>                 os.write(buf, 0, numRead);
>             }
>
> can anyone tell me what could be the reason?

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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate