Convert video files to base64 string

1, the video file is converted to base64

/ ** 
     * 
     * @param videofilePath video file path with the file name 
     * @return Base64 
     * / 
    public static String videoToBase64 (File videofilePath) { 
        Long videofilePath.length size = (); 
        byte [] = new new byte imageByte [(int) size ]; 
        the FileInputStream FS = null; 
        BufferedInputStream BIS = null; 
        the try { 
            FS = new new the FileInputStream (videofilePath); 
            BIS BufferedInputStream new new = (FS); 
            bis.read (imageByte); 
        } the catch (a FileNotFoundException E) { 
            log.info ( "file "+ videofilePath.getName () +" can not be found: {} ", e.getMessage ()); 
        } the catch (IOException E) {
            log.info ( "byte conversion BASE64 Error:" + e.getMessage ()); 
        } the finally { 
            IF (BIS = null!) { 
                the try { 
                    bis.close (); 
                } the catch (IOException E) { 
                    log.info ( " closing the input stream has an error: "+ e.getMessage ()); 
                } 
            } 
            ! IF (FS = null) { 
                the try { 
                    fs.Close (); 
                } the catch (IOException E) { 
                    log.info (" Close input outflow error: " e.getMessage + ()); 
                } 
            } 
        } 
        return (new new sun.misc.BASE64Encoder ()) encode (imageByte);. 
    }

 

Guess you like

Origin www.cnblogs.com/Small-sunshine/p/12482234.html