...
Use a variable of type int to capture the return value of the byte input method. When the value returned by read() is not -1, it can be safely cast to type byte. When read() returns 0XFF 0x000000FF, the comparison will test 0x000000FF against 0xFFFFFFFF and fail, which evaluates to false.
| Code Block | ||
|---|---|---|
| ||
FileInputStream in;
// initialize stream
int inbuff;
byte data;
while ((inbuff = in.read()) != -1) {
data = (byte) inbuff;
// ...
}
|
...
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="c09dfc1f9cc09f13-99f331be-459e4473-b624a515-1420b1e6f44ba249f7dedaf7"><ac:plain-text-body><![CDATA[ | [[API 2006 | AA. Bibliography#API 06]] | Class | ]]></ac:plain-text-body></ac:structured-macro> | |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="855b05c42c32c043-df5c9609-4b1c4215-90328e22-a403b38ece368ce4a7ebb238"><ac:plain-text-body><![CDATA[ | [[JLS 2005 | AA. Bibliography#JLS 05]] | [§4.2 | http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html#4.2] "Primitive Types and Values" | ]]></ac:plain-text-body></ac:structured-macro> |
<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="f969cd36bfdbeca3-97c294e4-44b64ac4-8c55bab5-91a6495608829076852c2813"><ac:plain-text-body><![CDATA[ | [[Pugh 2008 | AA. Bibliography#Pugh 08]] | "Waiting for the end" | ]]></ac:plain-text-body></ac:structured-macro> |
...