BinaryRead
✖
BinaryRead
reads one byte of raw binary data from an input stream, and returns an integer from 0 to 255.
Details and Options



- Possible types to read are:
-
"Byte" 8‐bit unsigned integer "Character8" 8‐bit character "Character16" 16‐bit character "Character32" 32-bit character "Complex64" IEEE single‐precision complex number "Complex128" IEEE double‐precision complex number "Complex256" IEEE quad‐precision complex number "Integer8" 8‐bit signed integer "Integer16" 16‐bit signed integer "Integer24" 24-bit signed integer "Integer32" 32‐bit signed integer "Integer64" 64‐bit signed integer "Integer128" 128‐bit signed integer "Real32" IEEE single‐precision real number "Real64" IEEE double‐precision real number "Real128" IEEE quad‐precision real number "TerminatedString" null‐terminated string of 8‐bit characters "UnsignedInteger8" 8‐bit unsigned integer "UnsignedInteger16" 16‐bit unsigned integer "UnsignedInteger24" 24-bit unsigned integer "UnsignedInteger32" 32‐bit unsigned integer "UnsignedInteger64" 64‐bit unsigned integer "UnsignedInteger128" 128‐bit unsigned integer - The first argument to BinaryRead can be InputStream["name",n], or simply "name" if there is at most one open input stream with the specified name. BinaryRead will call OpenRead to open files with no associated stream.
- BinaryRead[File["file"],…] is also supported.
- You can open a file or pipe to get an InputStream object using OpenRead.
- Streams for use with BinaryRead should be opened with BinaryFormat->True.
- There is always a "current point" maintained for any stream. When you read an object from a stream, the current point is left after the input you read. Successive calls to BinaryRead can therefore be used to read successive objects in a stream such as a file.
- BinaryRead returns EndOfFile if you are at the end of the file.
- BinaryRead returns Infinity for IEEE "infinity", and Indeterminate for IEEE "not‐a‐number".
- The following options can be given:
-
ByteOrdering $ByteOrdering what byte ordering to use Path $Path the path to search for files to be opened
Examples
open allclose allBasic Examples (1)Summary of the most common use cases
Create a file with a sequence of bytes:

https://wolfram.com/xid/0bdp1m0nu-p7qnhk

https://wolfram.com/xid/0bdp1m0nu-x9b56t

https://wolfram.com/xid/0bdp1m0nu-wrqzkn
Read the first byte from the file:

https://wolfram.com/xid/0bdp1m0nu-w3sh1x

Read the second byte as an 8-bit character:

https://wolfram.com/xid/0bdp1m0nu-zm9hrg

Read the next byte as an 8-bit signed integer:

https://wolfram.com/xid/0bdp1m0nu-bu70lu


https://wolfram.com/xid/0bdp1m0nu-45tber
Scope (1)Survey of the scope of standard use cases
Read bytes from the file specified using File object:

https://wolfram.com/xid/0bdp1m0nu-cl2mlm


https://wolfram.com/xid/0bdp1m0nu-z5h4gl

https://wolfram.com/xid/0bdp1m0nu-g7ym3n


https://wolfram.com/xid/0bdp1m0nu-ckjsle


https://wolfram.com/xid/0bdp1m0nu-cjnmvw


https://wolfram.com/xid/0bdp1m0nu-svexs

https://wolfram.com/xid/0bdp1m0nu-fe2f3
Wolfram Research (2004), BinaryRead, Wolfram Language function, https://reference.wolfram.com/language/ref/BinaryRead.html (updated 2019).
Text
Wolfram Research (2004), BinaryRead, Wolfram Language function, https://reference.wolfram.com/language/ref/BinaryRead.html (updated 2019).
Wolfram Research (2004), BinaryRead, Wolfram Language function, https://reference.wolfram.com/language/ref/BinaryRead.html (updated 2019).
CMS
Wolfram Language. 2004. "BinaryRead." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2019. https://reference.wolfram.com/language/ref/BinaryRead.html.
Wolfram Language. 2004. "BinaryRead." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2019. https://reference.wolfram.com/language/ref/BinaryRead.html.
APA
Wolfram Language. (2004). BinaryRead. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/BinaryRead.html
Wolfram Language. (2004). BinaryRead. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/BinaryRead.html
BibTeX
@misc{reference.wolfram_2025_binaryread, author="Wolfram Research", title="{BinaryRead}", year="2019", howpublished="\url{https://reference.wolfram.com/language/ref/BinaryRead.html}", note=[Accessed: 19-April-2025
]}
BibLaTeX
@online{reference.wolfram_2025_binaryread, organization={Wolfram Research}, title={BinaryRead}, year={2019}, url={https://reference.wolfram.com/language/ref/BinaryRead.html}, note=[Accessed: 19-April-2025
]}