code: public static byte[] readBytesFromFile(File f) {
          byte[] bytes = null;
          try {
              int filesize = (int) f.length();
              bytes = new byte[filesize];
              DataInputStream in = new DataInputStream(new FileInputStream(f));
              in.readFully(bytes);
              in.close();
          } catch (Exception e) {
              System.out.println("Error reading byte[] from file: "
                      + e.getMessage());
              return null;
          }
          return bytes;
      }
docs: Reads in a file as a byte[]