I hear that: FileReader is high-level stream, BufferedReader is low-level stream, and following this website :http://way2java.com/io/chaining-of-streams/
" Rules of chaining
If streams are chained just like that, you will land in compilation errors. Following rules are to be followed.
- The input for a high-level stream may come from a low-level stream or another high-level stream. That is, in programming, the constructor of a high-level stream can be passed with an object of low-level or high-level.
- Being low-level, the low-level stream should work by itself. It is not entitled to get passed with any other stream"
But:
`
public class CopyLines {
public static void main(String[] args) throws IOException {
BufferedReader inputStream = null;
PrintWriter outputStream = null;
try {
inputStream = new BufferedReader(new FileReader("xanadu.txt"));// not like above website say
outputStream = new PrintWriter(new FileWriter("characteroutput.txt"));
String l;
while ((l = inputStream.readLine()) != null) {
outputStream.println(l);
}
} finally {
if (inputStream != null) {
inputStream.close();
}
if (outputStream != null) {
outputStream.close();
}
}
}
}`
Someone tell me, why code above also correct