So why we need FileReader? What is its function? Why can't we just have: ... = new BufferedReader("personDataBase")?
How is FileWriter different from BufferedWriter, and vice versa?
when I work on unix, and I want to feed a file to a class, I type: java HelloWorld greeting.txt
What are PrintStream class and PrintWriter class?
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
fred rosenberger wrote:
So why we need FileReader? What is its function? Why can't we just have: ... = new BufferedReader("personDataBase")?
When you bake a cake, do the directions say "plant some grain, wait 6 months, harvest it, grind the seeds into a white powder. You will need two cups of that powder" or does it say "get two cups of flour"?
The idea here is that each of these objects do a little something, and you build off what others have done. And sometimes, you may what whole wheat flour, sometimes cake flower, sometimes all purpose flour...there may be times when you would want to pass something other than a FileReader into a BufferedReader.
Campbell Ritchie wrote:There should be lots in the Java™ Tutorials; look for the "buffered" subsection.
Jason K. (AC)
Jason Koonce wrote:One way of looking at the differences is in steps. With FileReader you read what? Just the characters, right? so what do you read should you have something other than simple characters? What if you tried storing multiple lines, serialized objects, or arrays? The stored information would simply read as a sentence for the FileReader.
BufferedReader, on the other hand, is more diverse in its capabilities. Using the information it receives from the FileReader it translates that information into meaningful code as well as Strings, should there be any, for you to then convert and manipulate in your program without adding a lot of additional, already been done for you, code.
Jason K. (AC)
Jason K. (AC)
Jason Koonce wrote:;
Now, below that is a bunch of methods, class summaries and things like that. Basically, what this is, is a small description in semi-plain English about what the class does. In this case it takes byte code and translates it to characters for other readers to make use of. In other words, a serialized non-text file that was stored as byte-code.
. . . and see the output with and without -c.javac Foo.java
javap -c Foo
javap Foo
Cheryl Scodario wrote:Hey Jason! Thanks as always. I am just wondering what does a byte-code looks like? Because I feel like so far I have been using text file that contains strings. But I did use InputStreamReader once, but I don't remember why?
Jason K. (AC)
My favorite is a chocolate cupcake with white frosting and tiny ad sprinkles.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|