class hello {
public static void main(String[] args) throws IOException {
FileInputStream input = new FileInputStream("xxx.txt");
ByteArrayOutputStream boi = new ByteArrayOutputStream();
byte[] BA = new byte[5];
int b ;
while((b = input.read(BA)) != -1) {
boi.write(BA,0,b);
}
System.out.println(boi);
input.close();
}
运行结果: