//创建字节对象

 byte[] buffer;

File file = new File("d://文件转字节测试文档.txt");

FileInputStream fis = new FileInputStream(file);
ByteArrayOutputStream baos = new ByteArrayOutputStream(fis.available());
byte[] bytes = new byte[fis.available()];
int temp;
while ((temp = fis.read(bytes)) != -1) {
          baos.write(bytes, 0, temp);
}
fis.close();
baos.close();
buffer = baos.toByteArray();

怎么把文件对象转化为字节流

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-18
  • 2021-08-27
  • 2021-10-11
相关资源
相似解决方案