2

I have only used Java Channels and BufferedOutputStream and the input counter part for reading and writing simple integers and some strings here and there to the file.
However I do not understand the use of all these classes when there is java.util.Scanner class that provides easy ways to read and write to the files.
Java veterans please tell me the use of Channels and Streams over Scanner.

3
  • 2
    Have you taken a look at docs.oracle.com/javase/tutorial/essential/io/index.html ? Commented Sep 11, 2012 at 14:23
  • 3
    For one thing, java.util.Scanner can not be used to write to files. Commented Sep 11, 2012 at 14:25
  • @MartijnVerburg: Nope, I was using Ivor Horton's book. Commented Sep 11, 2012 at 14:27

1 Answer 1

2

You use Java Channels for applications that have much more traffic coming to them, not just for simple stuff. Same goes, (kind of) for buffered IO. If you're writing to a file, and you're using any considerable amount of output, then you're going to want to use a buffered IO driver. If you're reading from a file, and don't have to read that much information, use Scanner, otherwise, use buffered IO.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.