Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #11105
| From | Tom Anderson <twic@urchin.earth.li> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: BufferedWriter cannot handle InterruptedIOException |
| Date | 2012-01-08 14:12 +0000 |
| Organization | Stack Usenet News Service |
| Message-ID | <alpine.DEB.2.00.1201081409510.20221@urchin.earth.li> (permalink) |
| References | <je241r$pon$1@news.albasani.net> |
On Wed, 4 Jan 2012, Jan Burse wrote:
> But I think this does not carry over to BufferedOutputStream. I
> find the following code there:
>
> /** Flush the internal buffer */
> private void flushBuffer() throws IOException {
> if (count > 0) {
> out.write(buf, 0, count);
> count = 0;
> }
> }
>
> In case that out throws an InterruptedIOException exception,
> the write operation is directly terminated, and the count
> is not set to zero.
>
> As an effect next time flushBuffer is called again, the
> same bytes are written out again.
What should happen? The field should be set to zero? That means that if
the interruption occurred *before* the bytes got written out, then they
will be lost forever.
The problem with InterruptedIOException, like any IOException, is that
there is no way to know what point in the IO operation it occurred.
Really, at that point, the only safe thing to do is to close the stream
and start again from scratch.
tom
--
music is a interesting thing, DUN COMPARE AND PUT IT TO BLAR BLAR GENRE,
THIS IS A STUPID ACT......MUSIC IS SAME TO EVERYONE -- sihamze
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Find similar | Unroll thread
BufferedWriter cannot handle InterruptedIOException Jan Burse <janburse@fastmail.fm> - 2012-01-04 18:59 +0100 Corr: BufferedOutputStream cannot handle InterruptedIOException Jan Burse <janburse@fastmail.fm> - 2012-01-04 19:00 +0100 Re: BufferedWriter cannot handle InterruptedIOException Daniel Pitts <newsgroup.nospam@virtualinfinity.net> - 2012-01-04 13:41 -0800 Re: BufferedWriter cannot handle InterruptedIOException Tom Anderson <twic@urchin.earth.li> - 2012-01-08 14:12 +0000
csiph-web