package ch02;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
public class FileInputStreamTest4 {
public static void main(String[] args) {
try(FileInputStream fis = new FileInputStream("assets/input2.txt")){
byte[] bs = new byte[10];
//배열이 10개라 10/10/6이지만 10개를 채워서 다읽게된다
//ABCDEFGHIJKLMNOPQRSTUVWXYZ(QRST)
int i;
while ((i = fis.read(bs))!=-1) {
//나온 숫자만큼만 읽어라.
// for (byte b : bs) {
// System.out.print((char)b);
// }
for (int j = 0; j < i; j++) {
System.out.print((char)bs[j]);
}
System.out.println(" : " + i + " 바이트 읽음");
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}