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;
    }
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.

@param path
@return a byte array of the file
@throws IOException
If there are errors reading the file