栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

base64编码音频文件并作为字符串发送,然后解码该字符串

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

base64编码音频文件并作为字符串发送,然后解码该字符串

您正在大量混合

String
s和
byte[]
s。不要那样做
如果要将a编码
byte[]
String
,请使用
base64.enpreToString()
,而不是将其编码为字节,
然后 创建一个字符串。

如果我尝试使用os.write(depredBytes)保存depredBytes,则可以正常工作,但在转换为String并使用getBytes()时不起作用。

呼叫

newString(byte[])
并没有执行您认为的操作。

同样用于

base64.depre(String,int)
解码字符串。

像这样的东西 (未经测试):

File file = new File(Environment.getExternalStorageDirectory() + "/hello-4.wav");byte[] bytes = FileUtils.readFileToByteArray(file);String enpred = base64.enpreToString(bytes, 0);      Utilities.log("~~~~~~~~ Enpred: ", enpred);byte[] depred = base64.depre(enpred, 0);Utilities.log("~~~~~~~~ Depred: ", Arrays.toString(depred));try{    File file2 = new File(Environment.getExternalStorageDirectory() + "/hello-5.wav");    FileOutputStream os = new FileOutputStream(file2, true);    os.write(depred);    os.close();}catch (Exception e){    e.printStackTrace();}

但是,为什么首先要对音频文件进行base64编码?



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/438207.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号