需要将文件转成的Base64字符串放在本地,等需要播放的时候再将Base64转换成mp3文件。但转成的Base64字符串一直有乱码问题,同样的方法图片没有乱码问题,下面贴出代码
public static String fileToBase64(String path) throws Exception {
File file = new File(path);
FileInputStream inputFile = new FileInputStream(file);
byte[] buffer = new byte[(int) file.length()];
inputFile.read(buffer);
inputFile.close();
return new BASE64Encoder().encode(buffer);
}