=========================================================================
使用过程中,一定要注意close()掉各个读写流!!!!!
=========================================================================
1、将File、FileInputStream 转换为byte数组:
【new File(参数) 参数可以写绝对路径,也可以如下,写一个文件名,则本文件会生成在该项目的本目录下或者从本项目的根目录下查询是否有本文件】
File file = new File("test.txt"); InputStream input = new FileInputStream(file); byte[] byt = new byte[input.available()]; input.read(byt);
2、将byte数组转换为InputStream:
byte[] byt = new byte[1024]; InputStream input = new ByteArrayInputStream(byt);
3、将byte数组转换为File:
File file = new File(‘‘); OutputStream output = new FileOutputStream(file); BufferedOutputStream bufferedOutput = new BufferedOutputStream(output); bufferedOutput.write(byt);
=================================================================
参考地址:https://www.cnblogs.com/DylanZ/p/6269042.html
=================================================================
原文地址:https://www.cnblogs.com/sxdcgaq8080/p/8404404.html
时间: 2024-11-08 09:07:52