English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Use a binary data structure called binary to store a large amount of raw data. Binary files store data in a more space-saving way than lists or tuples, and the runtime system is optimized for efficient input and output of binary files. Binary files are written and printed in the form of an integer or string sequence, enclosed in less than or greater than brackets.
The following is an example of a binary file in Erlang−
-module(helloworld). -export([start/0]). start() -> io:fwrite("~p~n",[<<5,10,20>>]), io:fwrite("~p~n",[<<"hello">>]).
Output Result:
<<5,10,20>> <<"hello">>
Let's see the Erlang functions that can be used to handle binary files -
Serial Number | Methods and Descriptions |
---|---|
1 | This method is used to convert an existing list to a binary list. |
2 | This method is used to split a binary list according to the specified index position. |
3 | This method is used to convert terms to binary. |
4 | This method is used to check if a bitstring is indeed a binary value. |
5 | This method is used to extract a part of a binary string. |
6 | This method is used to convert binary values to floating-point values. |
7 | This method is used to convert binary values to integer values. |
8 | This method is used to convert binary values to lists. |
9 | This method is used to convert binary values to atoms. |