While trying to do some operation with files the code goes like this,
File file=new File("aaa.txt");
I saw in a program BufferedReader and InputStreamReader were also included can you explain this with a simple example? I read in many sites about file handling but still its confusing!!!!
The
Fileclass is essentially a file descriptor which allows you to get a handle on the file, but doesn’t in and of itself have methods to read the information from the file.That is where the
InputStreamReadercomes in. AnInputStreamReader(and more easily its subclass theFileReader) will do the reading for you (there are other ways to do it, but this is one of the easiest).The
BufferedReaderwill wrap theInputStreamReaderand will read the file into a buffer (rather than simply converting and returning the bytes after every read invocation) allowing you to more easily read in the data.