Thanks,
Pramod
Thanks,
Pramod
pramod talekar wrote:Is there any way to avoid BufferedReader as it is the only one which provides readLine which returns String.
Also how to read multiple lines as readLine terminates after reading a line.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Thanks,
Pramod
Thanks,
Pramod
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
Thanks,
Pramod
I suspect that class PrintStream is an old, legacy class. The documentation says it exists since Java 1.0. Class PrintWriter was new in Java 1.1. Probably the idea of Readers and Writers for character data was invented in Java 1.1. But for backward compatibility reasons, class PrintStream remained in Java version 1.1 and newer, and the type of System.out still remains PrintStream for compatibility reasons.
When you need to write character data yourself, and you have to decide whether to use PrintStream or PrintWriter, always choose PrintWriter. Note that PrintStream doesn't allow you to choose the character encoding - it will always use the platform's default character encoding, which is not always what you want.
Thanks,
Pramod
pramod talekar wrote:I wonder why FileReader takes so many statements to read from a file compared to FileWriter which takes very few while writing to a file.
sandy chops wrote:If you don't want to use while loop, and if the file size is less then Integer.MAX_VALUE you can use below code
pramod talekar wrote:Does it mean that OutputStream & InputStream were originally written to have both binary & character form and only after 1.1 they were restricted to byte but PrintStream was allowed to have both binary & char?
pramod talekar wrote:Also how were we able to write in a char form before Java 1.1 as PW was new in Java 1.1?
Thanks,
Pramod
pramod talekar wrote:So what I understand as of now is that though PrintStream is extended from OutputStream, it has added functionality of handling char as well.
pramod talekar wrote:The newly designed Reader & Writer are better than PrintStream for writing char format because of the mentioned reasons by you & also it can't be reverted now to just byte form as that will cause compatibility issue.
Just the other day, I was thinking ... about this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|