首页
IT
登录
6mi
u
盘
搜
搜 索
IT
读输入流的字节,打印显示
读输入流的字节,打印显示
xiaoxiao
2021-03-26
21
File file = new File("C:\\Users\\Administrator\\Desktop\\a.txt"); FileInputStream fis = new FileInputStream(file); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); byte[] buffer = new byte[file.length()]; int len = 0; while((len = fis.read(buffer))!=-1){ outStream.write(buffer, 0, len); } fis.close(); outStream.close(); byte[] data = outStream.toByteArray(); String str = new String(data); System.out.println(str); }
转载请注明原文地址: https://ju.6miu.com/read-661395.html
技术
最新回复
(
0
)