转换的Mp3 Byte数组为String [英] Converting Mp3 to Byte array to String

查看:208
本文介绍了转换的Mp3 Byte数组为String的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何一个可以说我该怎么MP3文件转换为字节数组,字节数组中的Andr​​oid应用程序的字符串,反之亦然。其被存储在从介质夹源码数据库或装载mp3文件。

Can any one say how can I convert mp3 file to byte array,byte array to string and vice versa in android application. The mp3 file which is stored in sqlite database or loading from media folder.

在此先感谢

推荐答案

您不应该存储介质的数据到数据库中。使用文件系统,并将与路径文件名到数据库...也许有喜欢音乐,bytesize等长一些额外的元信息。

You should not store media data into the database. Use the filesystem and place the the filename with path into the database... maybe with some additional meta information like length of the music, bytesize etc.

这将有不同的服务更多的好处。第一个是,MP3是流媒体不错。如果您将其用于存储一个字符串,你不得不读孔的东西到内存,而不是一个组成部分。重新考虑你的申请,如果有人存储与百兆到有声读物应用你

This will have more benefit for different services. The first is, that mp3 is nice for streaming. If you use a string for storage, you had to read the hole thing into the memory rather than a part. Rethink your application if someone stores audiobooks with hundred megabytes into you app.

如果你真的需要这个你应该把你的MP3作为一个二进制文件,后期将其转换为base64。

If you really need to this you should treat your mp3 as a binary file and convert it late to base64.

请参阅(例如)

  • File to byte[] in Java
  • Decode Base64 data in Java

这篇关于转换的Mp3 Byte数组为String的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆