Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #34481
| From | Jan Burse <janburse@fastmail.fm> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: OutputStream.write(int) |
| Date | 2016-06-06 01:45 +0200 |
| Organization | albasani.net |
| Message-ID | <nj2di3$k1h$1@news.albasani.net> (permalink) |
| References | <nj2ajp$4h$1@Gaia.teknon.de> |
Hi
Well, its a byte stream. I doubt that you can convey something
in the higher 24-bits in some implementation.
At least we can say that 0x000000 and 0xFFFFFF must be ignored,
otherwise the default implementation of write(byte[],..) gets
broken:
public void write(byte b[], int off, int len) throws IOException {
if (b == null) {
throw new NullPointerException();
} else if ((off < 0) || (off > b.length) || (len < 0) ||
((off + len) > b.length) || ((off + len) < 0)) {
throw new IndexOutOfBoundsException();
} else if (len == 0) {
return;
}
for (int i = 0 ; i < len ; i++) {
write(b[off + i]);
}
}
But an Outputstream might also overwrite this method, it is
not a final method. But most likely we want:
write(x) does the same as
write(new byte[]{(byte)x})
And the above invariant wouldn't hold if we were to interpret
the upper 24-bits.
Bye
Volker Borchert schrieb:
> The javadoc as of 1.8 states: "The 24 high-order bits of b are ignored."
> Are they really? I.o.w., has anybody encountered broken implementations
> that don't, and where?
>
> vb
>
>
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
OutputStream.write(int) v_borchert@despammed.com (Volker Borchert) - 2016-06-05 22:54 +0000
Re: OutputStream.write(int) Jan Burse <janburse@fastmail.fm> - 2016-06-06 01:45 +0200
Re: OutputStream.write(int) v_borchert@despammed.com (Volker Borchert) - 2016-06-06 03:19 +0000
Re: OutputStream.write(int) Jan Burse <janburse@fastmail.fm> - 2016-06-06 11:58 +0200
Re: OutputStream.write(int) v_borchert@despammed.com (Volker Borchert) - 2016-06-06 15:51 +0000
Re: OutputStream.write(int) Arne Vajhøj <arne@vajhoej.dk> - 2016-06-05 20:09 -0400
Re: OutputStream.write(int) Kevin McMurtrie <mcmurtrie@pixelmemory.us> - 2016-06-05 19:38 -0700
csiph-web