Package io.bin
Class BinaryIO
java.lang.Object
io.bin.BinaryIO
Some small methods to speed up binary file reading and writing
- Since:
- 13.12.2021
- Author:
- Juyas
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic ByteBuffer
Reads byte data from a file.static ByteBuffer
Reads data from an URL in the web.static void
Writes raw bytes to a file.
-
Constructor Details
-
BinaryIO
public BinaryIO()
-
-
Method Details
-
readData
Reads data from an URL in the web. It produces a byte array containing all read data from the source with no trailing zeros.- Parameters:
url
- the web urlblockSize
- the byte blocks that will be requested at once - bigger blocks might improve speed based on connection- Returns:
- a
ByteBuffer
containing all read bytes - Throws:
IOException
-
readData
Reads byte data from a file. UsesFiles.readAllBytes(Path)
.- Parameters:
file
- the file to read- Returns:
- a
ByteBuffer
containing all read bytes - Throws:
IOException
-
writeData
Writes raw bytes to a file. There is no check for an existing file.- Parameters:
file
- the file to write todata
- the data to write- Throws:
IOException
-