package rxxj;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import static java.lang.System.in;
public class Life {
public static void main(String[] args) {
String fileName = "D:/all/demo/day/src/rxxj/text.txt";
readFileByOneType(fileName);
}
public static void readFileByOneType(String fileName) {
File file = new File(fileName);
try {
FileInputStream in = new FileInputStream(file);
int onebyte;
while ((onebyte = in.read()) != -1) {//每次读取一字节数据,返回值为-1表示读完
System.out.write(onebyte);
}
} catch (Exception e) {
e.printStackTrace();
return;
} finally {
if (in != null) {
try {
in.close();//关闭输入流
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
输出结果