Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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.

share|improve this question
2  
Have you taken a look at docs.oracle.com/javase/tutorial/essential/io/index.html ? –  Martijn Verburg Sep 11 '12 at 14:23
3  
For one thing, java.util.Scanner can not be used to write to files. –  Michael Borgwardt Sep 11 '12 at 14:25
    
@MartijnVerburg: Nope, I was using Ivor Horton's book. –  Dummy Derp Sep 11 '12 at 14:27

1 Answer 1

up vote 2 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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