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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ByteBufferReads byte data from a file.static ByteBufferReads data from an URL in the web.static voidWrites 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
ByteBuffercontaining all read bytes - Throws:
IOException
-
readData
Reads byte data from a file. UsesFiles.readAllBytes(Path).- Parameters:
file- the file to read- Returns:
- a
ByteBuffercontaining 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
-