简体   繁体   English

在Android中将视频文件转换为字节数组

[英]convert video files to byte array in android

In my android application i am recording and saving the file in sdcard. 在我的Android应用程序中,我正在记录文件并将其保存在sdcard中。 Now i would like to convert this saved file to byte array and sent it to the server. 现在,我想将此保存的文件转换为字节数组,并将其发送到服务器。

Could anyone please let me know as how can i convert video files to byte array 任何人都可以让我知道如何将视频文件转换为字节数组

Please forward your valuable suggestions. 请转发您的宝贵建议。

Thanks in advance :) 提前致谢 :)

try this: 尝试这个:

String strFile=null;
File file=new File(pathOnSdCard);
try {
byte[] data = FileUtils.readFileToByteArray(file);//Convert any file, image or video into byte array
strFile = Base64.encodeToString(data, Base64.NO_WRAP);//Convert byte array into string
} catch (IOException e) {
e.printStackTrace();
}
return strFile;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM