about the IO, I have two questions.
A. In a tutorial and some StackOverflow answers, they claimed that FileInputStream is not buffered. is that true ?
The following code use FileInputStream to read data into a byte array(1024 bytes)
class Test {
public static void main(String[] args) throws IOException {
FileInputStream fis = new FileInputStream("./fos.txt");
FileOutputStream fos = new FileOutputStream("./copy.txt");
byte[] buffer = new byte[1024]; // Is this a buffer ?
int len;
while ((len = fis.read(buffer))!= -1) {
fos.write(buffer);
}
fos.close();
fis.close();
}
}
From the API, there is one line:
public int read(byte b[]) throws IOException
- @param b: the buffer into which the data is read.
B. If they are both buffered, they both put the data into the buffer, and fetch the data from the buffer, where exactly is the place that makes BufferedInputStream faster than FileInputStream?
Thank you