It seems there are different ways to read and write data of files in Java.
I want to read ASCII data from a file. What are the possible ways and their differences?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
ASCII is a TEXT file so you would use
Readersfor reading. Java also supports reading from a binary file usingInputStreams. If the files being read are huge then you would want to use aBufferedReaderon top of aFileReaderto improve read performance.Go through this article on how to use a
ReaderI’d also recommend you download and read this wonderful (yet free) book called Thinking In Java
In Java 7:
(docs)
or
(docs)
In Java 8:
(docs)