commons-file/src/main/java/info/monitorenter/util/FileUtil.java
public static byte[] readRAM(final File f) throws IOException {
    final int total = (int) f.length();
    final byte[] ret = new byte[total];
    final InputStream in = new FileInputStream(f);
    try {
      int offset = 0;
      int read = 0;
      do {
        read = in.read(ret, offset, total - read);
        if (read > 0) {
          offset += read;
        }
      } while ((read != -1) && (offset != total));
      return ret;
    } finally {
      in.close();
    }
  }
public static byte[] readRAM(final File f) throws IOException {
    final int total = (int) f.length();
    final byte[] ret = new byte[total];
    final InputStream in = new FileInputStream(f);
    try {
      int offset = 0;
      int read = 0;
      do {
        read = in.read(ret, offset, total - read);
        if (read > 0) {
          offset += read;
        }
      } while ((read != -1) && (offset != total));
      return ret;
    } finally {
      in.close();
    }
  }
public static byte [ ] readRAM ( final File f ) throws IOException { final int total = ( int ) f . length ( ) ; final byte [ ] ret = new byte [ total ] ; final InputStream in = new FileInputStream ( f ) ; try { int offset = 0 ; int read = 0 ; do { read = in . read ( ret , offset , total - read ) ; if ( read > 0 ) { offset += read ; } } while ( ( read != - 1 ) && ( offset != total ) ) ; return ret ; } finally { in . close ( ) ; } }
Reads the content of the given File into an array.
<p>
This method currently does not check for maximum length and might cause a
java.lang.OutOfMemoryError. It is only intended for
performance-measurements of data-based algorithms that want to exclude
I/O-usage.
<p>

@param f
the file to read.

@throws java.io.IOException
if something goes wrong.

@return the contents of the given file.
Reads the content of the given File into an array . <p > This method currently does not check for maximum length and might cause a java . lang . OutOfMemoryError . It is only intended for performance - measurements of data - based algorithms that want to exclude I / O - usage . <p >