ByteArrayFormatQ[ba,"fmt"]
gives True if the ByteArray object ba might be imported as format "fmt" and gives False otherwise.
ByteArrayFormatQ[ba,{"fmt1","fmt2",…}]
gives True if ba might be imported as one of "fmti".
ByteArrayFormatQ
Listing of Formats »ByteArrayFormatQ[ba,"fmt"]
gives True if the ByteArray object ba might be imported as format "fmt" and gives False otherwise.
ByteArrayFormatQ[ba,{"fmt1","fmt2",…}]
gives True if ba might be imported as one of "fmti".
Details
- ByteArrayFormatQ attempts to identify whether a ByteArray object can be imported as a specific format.
- ByteArrayFormatQ uses heuristic methods and may not give correct results, particularly for shorter arrays.
- ByteArrayFormatQ does not verify that ImportByteArray would succeed if applied to ba.
Examples
open all close allBasic Examples (1)
Export an image to a GIF string:
ba = ExportByteArray[RadialGradientImage[Hue, 8, "Byte"], "GIF"]Check if the byte array might be a GIF:
ByteArrayFormatQ[ba, "GIF"]Check if the byte array might be a JPEG:
ByteArrayFormatQ[ba, "JPEG"]Check if the byte array might be in one of the image formats:
ByteArrayFormatQ[ba, {"PNG", "GIF", "JPEG"}]Scope (1)
Read in a text file as a byte array:
ba = ReadByteArray["ExampleData/Text/AliceInWonderland.txt"]Check if the byte array might be imported as the "Binary" format:
ByteArrayFormatQ[ba, "Binary"]Check if the byte array might be imported as the "Text" format:
ByteArrayFormatQ[ba, "Text"]Related Guides
History
Text
Wolfram Research (2020), ByteArrayFormatQ, Wolfram Language function, https://reference.wolfram.com/language/ref/ByteArrayFormatQ.html.
CMS
Wolfram Language. 2020. "ByteArrayFormatQ." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/ByteArrayFormatQ.html.
APA
Wolfram Language. (2020). ByteArrayFormatQ. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ByteArrayFormatQ.html
BibTeX
@misc{reference.wolfram_2026_bytearrayformatq, author="Wolfram Research", title="{ByteArrayFormatQ}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/ByteArrayFormatQ.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_bytearrayformatq, organization={Wolfram Research}, title={ByteArrayFormatQ}, year={2020}, url={https://reference.wolfram.com/language/ref/ByteArrayFormatQ.html}, note=[Accessed: 13-June-2026]}