I was reading about the BufferedReader class and looked at its read methods.
I noticed it overrides one of the two (non-abstract) read methods, read(char[] cbuf, int off, int len), but not read(char[] cbuf).
Because it does not override read(char[] cbuf), it makes me wonder if for reading an entire file into a char[] array more efficient than using read(char[] cbuf, int off, int len).
Which is better?
Or better yet, is there a better way of doing this:
Code://try catch finally excluded for simplicity File f = new File("abc.def"); char[] cbuf = new char[(int)f.length()]; //assuming the file is small enough BufferedReader br = new BufferedReader(new FileReader(f)); br.read(cbuf); //or br.read(cbuf, 0, (int)f.length()); ??? br.close();



Reply With Quote

Bookmarks