【发布时间】:2015-12-07 22:26:01
【问题描述】:
由于我使用的文件很大,我的函数返回一个超出其限制的字符串。
有没有办法创建一个返回字符串数组的函数,以便以后我可以级联它们并重新创建文件?
private String ConvertVideoToBase64()
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
FileInputStream fis;
try {
File inputFile = new File("/storage/emulated/0/Videos/out.mp4");
fis = new FileInputStream(inputFile);
byte[] buf = new byte[1024];
int n;
while (-1 != (n = fis.read(buf)))
baos.write(buf, 0, n);
byte[] videoBytes = baos.toByteArray();
fis.close();
return Base64.encodeToString(videoBytes, Base64.DEFAULT);
//imageString = videoString;
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
【问题讨论】:
标签: java android string base64 bytearray