public static byte [ ] fileToBytes ( File path ) throws IOException { FileInputStream fin = new FileInputStream ( path ) ; byte [ ] buffer = new byte [ ( int ) fin . getChannel ( ) . size ( ) ] ; try { if ( fin . read ( buffer ) == - 1 ) { throw new IOException ( "File " + path . getAbsolutePath ( ) + " is empty" ) ; } } finally { fin . close ( ) ; } return buffer ; }
Serialize a file into bytes . Used to serialize catalog and deployment file for UpdateApplicationCatalog on the client .