Class IOUtil

java.lang.Object
com.spinyowl.legui.util.IOUtil

public final class IOUtil extends Object
IO utility. Used to read resource as ByteBuffer or as String..
  • Method Details

    • resourceToByteBuffer

      public static ByteBuffer resourceToByteBuffer(String path) throws IOException
      Creates ByteBuffer from:
      • file
      • resource
      • url (http/https) protocol
      Parameters:
      path - path to file or resource.
      Returns:
      file or resource data or null.
      Throws:
      IOException - in case if any IO exception occurs.
    • resourceToByteBuffer

      public static ByteBuffer resourceToByteBuffer(InputStream stream) throws IOException
      Creates ByteBuffer from stream.
      Parameters:
      stream - stream to read.
      Returns:
      stream data or null.
      Throws:
      IOException - in case if any IO exception occurs.
    • resourceToByteBuffer

      public static ByteBuffer resourceToByteBuffer(File file) throws IOException
      Creates ByteBuffer from file.
      Parameters:
      file - file to read.
      Returns:
      file or null.
      Throws:
      IOException - in case if any IO exception occurs.
    • resourceToString

      public static String resourceToString(String path) throws IOException
      Creates String from file or resource.
      Parameters:
      path - path to file or resource.
      Returns:
      String from file or resource data or null.
      Throws:
      IOException - in case if any IO exception occurs.
    • resourceToString

      public static String resourceToString(InputStream stream) throws IOException
      Creates String from stream.
      Parameters:
      stream - stream to read.
      Returns:
      String from stream data or null.
      Throws:
      IOException - in case if any IO exception occurs.
    • resourceToString

      public static String resourceToString(File file) throws IOException
      Creates String from file.
      Parameters:
      file - file to read.
      Returns:
      String from file or null.
      Throws:
      IOException - in case if any IO exception occurs.
    • byteBufferToString

      public static String byteBufferToString(ByteBuffer byteBuffer)
      Used to transfer buffer data to String.
      Parameters:
      byteBuffer - data to transfer
      Returns:
      string or null.
    • byteBufferToString

      public static String byteBufferToString(ByteBuffer byteBuffer, Charset charset)
      Used to transfer buffer data to String.
      Parameters:
      byteBuffer - data to transfer
      Returns:
      string or null.