- package com.itheima;
- import java.io.FileInputStream;
- public class Test8 {
- public static void main(String[] args) throws Exception {
- FileInputStream in = new FileInputStream("C:\\exercise.txt");
- //文件里的内容: 中关村黑马程序员训练营heimacom.itheimahahaha xixixi
- byte[] temp = new byte[5];
- while(in.read(temp) != -1){
- System.out.print(new String(temp));//第三个字只能输出一半
- }
- //输出结果:中关?搴诼?程序?毖盗?营heimacom.itheimahahaha xixixiixix
-
-
- }
- }
复制代码 |