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.

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.