Android 把文件转换成字符流

xiaoxiao2021-02-28  101

/** * 这个是把文件变成二进制流 * * @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(); }
转载请注明原文地址: https://www.6miu.com/read-48491.html

最新回复(0)