Java reads the files in the specified path into the memory and saves the files in byte Arrays
/***** @ Param path file path * @ return convert the file to a byte array */public static byte [] getByteArrayFrom (String path) {byte [] result = null; byteArrayOutputStream outputStream = new ByteArrayOutputStream (); // create a File file = new File (path); FileInputStream fileInputStream = null; try {fileInputStream = new FileInputStream (file ); int len = 0; byte [] buffer = new byte [1024]; while (len = fileInputStream. read (buffer ))! =-1) {outputStream. write (buffer, 0, len);} result = outputStream. toByteArray ();} catch (Exception e) {// TODO Auto-generated catch blocke. printStackTrace ();} finally {if (fileInputStream! = Null) {try {fileInputStream. close (); fileInputStream = null;} catch (IOException e) {// TODO Auto-generated catch blocke. printStackTrace () ;}} return result ;}