import java.io.*;
public class M {
public static void main(String[] args) throws FileNotFoundException {
File file = new File("/filename");
FileInputStream fileInputStream = new FileInputStream(file);
BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream);
// 이거랑
byte[] buffer = new byte[8192];
try {
fileInputStream.read(buffer);
} catch(IOException e) {}
// 이거랑 차이가 뭐임?
try {
bufferedInputStream.read();
} catch (IOException e) {}
}
}
public class M {
public static void main(String[] args) throws FileNotFoundException {
File file = new File("/filename");
FileInputStream fileInputStream = new FileInputStream(file);
BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream);
// 이거랑
byte[] buffer = new byte[8192];
try {
fileInputStream.read(buffer);
} catch(IOException e) {}
// 이거랑 차이가 뭐임?
try {
bufferedInputStream.read();
} catch (IOException e) {}
}
}
BufferedInputStream이 내부의 자체 버퍼를 쓰기 때문에 빠르대
근데 InputStream에 read() 메소드 말고도 read(byte[] b)라는 버퍼 지원 메소드가 있잖아
이거 써도 BufferedInputStream 대비 성능 구림?
차이가 뭐야?
니말대로 버퍼가 충분히 크면 딱히 성능 차이 없는 거 맞음