code: public static byte[] readFile(String filePath) throws IOException {
          byte[] buffer = new byte[(int) new File(filePath).length()];
          BufferedInputStream f = null;
          try {
              f = new BufferedInputStream(new FileInputStream(filePath));
              f.read(buffer);
          } finally {
              if (f != null) {
                  try {
                      f.close();
                  } catch (final IOException ignored) {
                  }
              }
          }
          return buffer;
      }
docs: Reads a file.
  
  @param filePath The file path.
  @return a byte[] The file data.
  @throws java.io.IOException if an error occurs reading the file or if the file does not exists.