将音频文件转化为Base64位编码

时间:2025-03-01 16:00:49

import ;
import ;
import ;
import ;
import ;
import ;

import ;

import .BASE64Encoder;


/**

     * 将音频转化为base64位编码
     * */
    @ResponseBody
    @RequestMapping(value="tobase",method=)
    public String tobase64(String url){
    try{
    URL urlfile=new URL(url);
    // 下载网络文件
            int bytesum = 0;
            int byteread = 0;
                URLConnection conn = ();
                InputStream inStream = ();
                int size=();
                byte[] buffer = new byte[size];
                while ((byteread = (buffer)) != -1) {
                    (buffer);  
                    ();  
            String str=new BASE64Encoder().encode(buffer); 
            if(str!=null){
            str=((""),"");
            str=("=", "");
            str=(" ", "");
            }
            return str;
                }
   
    }catch(Exception e){
    ();
    }
    return null;
    }