src/main/java/com/spinyowl/legui/util/IOUtil.java
public static ByteBuffer resourceToByteBuffer(File file) throws IOException {
    if (!file.exists() || !file.isFile()) {
      throw new IllegalArgumentException("File does not exist or is not a file.");
    }
    InputStream stream = new FileInputStream(file);
    byte[] bytes = IOUtils.toByteArray(stream);
    ByteBuffer data = ByteBuffer.allocateDirect(bytes.length).order(ByteOrder.nativeOrder())
        .put(bytes);
    data.flip();
    return data;
  }
/**
   * Creates {@link ByteBuffer} from file.
   *
   * @param file file to read.
   * @return file or null.
   * @throws IOException in case if any IO exception occurs.
   */
Creates  ByteBuffer from file.
@param file file to read.
@return file or null.
@throws IOException in case if any IO exception occurs.
Creates ByteBuffer from file . @param file file to read . @return file or null . @throws IOException in case if any IO exception occurs .
public static ByteBuffer resourceToByteBuffer(File file) throws IOException {
    if (!file.exists() || !file.isFile()) {
      throw new IllegalArgumentException("File does not exist or is not a file.");
    }
    InputStream stream = new FileInputStream(file);
    byte[] bytes = IOUtils.toByteArray(stream);
    ByteBuffer data = ByteBuffer.allocateDirect(bytes.length).order(ByteOrder.nativeOrder())
        .put(bytes);
    data.flip();
    return data;
  }
public static ByteBuffer resourceToByteBuffer ( File file ) throws IOException { if ( ! file . exists ( ) || ! file . isFile ( ) ) { throw new IllegalArgumentException ( "File does not exist or is not a file." ) ; } InputStream stream = new FileInputStream ( file ) ; byte [ ] bytes = IOUtils . toByteArray ( stream ) ; ByteBuffer data = ByteBuffer . allocateDirect ( bytes . length ) . order ( ByteOrder . nativeOrder ( ) ) . put ( bytes ) ; data . flip ( ) ; return data ; }
Creates {@link ByteBuffer} from file.
Creates { @link ByteBuffer } from file .