Convertir archivos de vídeo a la cadena base64

1, el archivo de vídeo se convierte en base 64

/ ** 
     * 
     * @ param videofilePath ruta del archivo de vídeo con el nombre del archivo 
     * @return base 64 
     * / 
    public static cadena videoToBase64 (videofilePath Archivo) { 
        tamaño largo videofilePath.length = (); 
        byte [] = new imageByte nuevo byte [(int) tamaño ]; 
        el FS = FileInputStream nula; 
        BufferedInputStream BIS = null; 
        el try { 
            FS = new new FileInputStream (videofilePath); 
            BIS BufferedInputStream nuevos nuevos = (FS); 
            bis.read (imageByte); 
        } la captura (un FileNotFoundException E) { 
            log.info (archivo" "+ videofilePath.getName () +" no se puede encontrar: {}", e.getMessage ()); 
        } el catch (IOException e) {
            log.info ( "byte BASE64 conversión de error:" + e.getMessage ()); 
        } finally { 
            SI (BIS! = null) { 
                try { 
                    bis.close (); 
                } el catch (IOException e) { 
                    log.info ( " cerrando el flujo de entrada tiene un error: "+ e.getMessage ()); 
                } 
            } 
            if (FS = null) { 
                try { 
                    fs.Close (); 
                } el catch (IOException e) { 
                    log.info (" Cerca de error de salida de entrada: " e.getMessage + ()); 
                } 
            } 
        } 
        retorno (nuevo nuevo sun.misc.BASE64Encoder ()) encode (imageByte) ;. 
    }

 

Supongo que te gusta

Origin www.cnblogs.com/Small-sunshine/p/12482234.html
Recomendado
Clasificación