Package io.bin

Class BinaryIO

java.lang.Object
io.bin.BinaryIO

public class BinaryIO extends Object
Some small methods to speed up binary file reading and writing
Since:
13.12.2021
Author:
Juyas
  • Constructor Details

    • BinaryIO

      public BinaryIO()
  • Method Details

    • readData

      public static ByteBuffer readData(URL url, int blockSize) throws IOException
      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 url
      blockSize - 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

      public static ByteBuffer readData(File file) throws IOException
      Reads byte data from a file. Uses Files.readAllBytes(Path).
      Parameters:
      file - the file to read
      Returns:
      a ByteBuffer containing all read bytes
      Throws:
      IOException
    • writeData

      public static void writeData(File file, byte[] data) throws IOException
      Writes raw bytes to a file. There is no check for an existing file.
      Parameters:
      file - the file to write to
      data - the data to write
      Throws:
      IOException