FileTools[Binary]
Read
read binary data from a file
Calling Sequence
Parameters
Description
Examples
Compatibility
Read(file, type, num, opt1, opt2, ...)
file
-
file descriptor or filename
type
type of data to read
num
number of elements to read
byteorder = opt
(optional) byte order specification
output = identical(list,Vector,Array)
(optional) output format
The Read(file, type, num) command reads num elements in type format from a file and returns them in the form of a list.
The following are valid values for type: integer[1], integer[2], integer[4], integer[8], float[4], float[8]. These types represent hardware data types. The integer[n] is an n byte integer, and float[n] is an n byte float.
The byteorder argument can have one of four values: big, little, network, and native. This effects the order in which bytes are written for multi-byte data types.
- big and little specify big endian and little endian respectively
- network specifies network ordering (big endian)
- native uses the native byte ordering
If byteorder is not specified, it defaults to network.
The output argument lets you specify the return-value data structure used to store the binary data. Using output=Array or output=Vector can be more efficient as these data structures will keep the data in the specified hardware format without requiring any conversion. The default is output = list in order to be compatible with previous versions of Maple.
If file is the name of a file that has not been opened, Maple attempts to open the file before attempting to read the data.
An error is raised if file is not a valid descriptor or if it is the name of a file that does not exists.
num≔1⁢2563+2⁢2562+3⋅256+4
num≔16909060
num2≔4⁢2563+3⁢2562+2⋅256+1
num2≔67305985
FileToolsBinaryWrite⁡testfile,integer4,num
4
FileToolsBinaryClose⁡testfile:
FileToolsBinaryRead⁡testfile,integer4
16909060
FileToolsBinaryRead⁡testfile,integer4,byteorder=little
67305985
FileToolsRemove⁡testfile
The FileTools[Binary][Read] command was updated in Maple 2016.
The output parameter was updated in Maple 2016.
See Also
FileTools[AtEndOfFile]
FileTools[Binary][Close]
FileTools[Binary][ReadFile]
FileTools[Binary][Write]
FileTools[Remove]
IO_errors
Download Help Document