Skip to content
This repository has been archived by the owner on Jun 29, 2023. It is now read-only.

LUtilsInputStream reference

Lexize edited this page Sep 9, 2022 · 2 revisions

LUtilsInputStream

LUtils class that represents input stream.


read(): Integer
Returns integer in range from -1 to 255.
If value that was returned is -1, that means that you reached end of stream.

skip(Integer n): Integer
Skips specified amount of bytes in stream.
Return amount of bytes that was skipped.

reset()
Resets stream position.

close()
Closes stream.


How to use:

local file = lutils.file();
file:init("test_avatar_folder");
local input_stream = file:openReadStream("test.txt");

local byte_array = {};

local b = input_stream:read();

while b ~= -1 do
   byte_array[#byte_array+1] = b;
   b = input_stream:read();
end

print(#byte_array);
-- Will print length of byte array that was read from input stream
input_stream:close();