http://docs.oracle.com/javase/7/docs/api/index.html 찾아보시면 나옵니다.
BufferInputStream은 또 다른 InputStream에서 읽어오고, (byte 쓰긴씁니다)
FileInputStream은 바로 읽는것 같습니다.
BufferInputStream 은 FIS의 도우미 역활같은데(성능 업을 위한)...확실친 못하겠네요.
결론은.. BufferInputStream을 FileInputStream과 같이쓰면 성능 향상이 된다(?)
참고: http://i5on9i.egloos.com/4840636
참고: http://stackoverflow.com/questions/21641551/what-is-the-difference-between-fileinputstream-and-bufferedinputstream-in-java
참고: http://hyeonstorage.tistory.com/238
참고: http://stackoverflow.com/questions/18600331/why-is-using-bufferedinputstream-to-read-a-file-byte-by-byte-faster-than-using-f
참고: http://examples.javacodegeeks.com/
public class BufferedInputStreamExample {
public static void main(String[] args) {
File file = new File("inputfile.txt");
BufferedInputStream bin = null;
FileInputStream fin = null;
try {
// create FileInputStream object
fin = new FileInputStream(file);
// create object of BufferedInputStream
bin = new BufferedInputStream(fin);
// byte array to store input
byte[] contents = new byte[1024];
int bytesRead=0;
String s;
while ((bytesRead = bin.read(contents)) != -1) {
s = new String(contents, 0, bytesRead);
System.out.print(s);
}
}
catch (FileNotFoundException e) {
System.out.println("File not found" + e);
}
catch (IOException ioe) {
System.out.println("Exception while reading file " + ioe);
}
finally {
// close the streams using close method
try {
if (fin != null) {
fin.close();
}
if (bin != null) {
bin.close();
}
}
catch (IOException ioe) {
System.out.println("Error while closing stream : " + ioe);
}
}
}
}
public class FileInputStreamExample {
public static void main(String[] args) {
File file = new File("inputfile.txt");
FileInputStream fin = null;
try {
// create FileInputStream object
fin = new FileInputStream(file);
byte fileContent[] = new byte[(int)file.length()];
// Reads up to certain bytes of data from this input stream into an array of bytes.
fin.read(fileContent);
//create string from byte array
String s = new String(fileContent);
System.out.println("File content: " + s);
}
catch (FileNotFoundException e) {
System.out.println("File not found" + e);
}
catch (IOException ioe) {
System.out.println("Exception while reading file " + ioe);
}
finally {
// close the streams using close method
try {
if (fin != null) {
fin.close();
}
}
catch (IOException ioe) {
System.out.println("Error while closing stream: " + ioe);
}
}
}
}