/**
* 这个是把文件变成二进制流
*
* @param imagepath
* @return
* @throws Exception
*/
public static byte[] readStream(String imagepath) throws Exception {
FileInputStream fs = new FileInputStream(imagepath);
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = 0;
while (-1 != (len = fs.read(buffer))) {
outStream.write(buffer, 0, len);
}
outStream.close();
fs.close();
return outStream.toByteArray();
}
Android 把文件转换成字符流
最新推荐文章于 2024-09-13 00:36:20 发布