Please tell me how to read plain text files in Java

Asked 1 years ago, Updated 1 years ago, 132 views

Java seems to have a variety of ways to read and write data in a file.

I want to read ASCII data from the file. Please explain what are the methods and what are the differences between them.

ascii java file-io

2022-09-22 14:38

1 Answers

ASCII is a text file. You should use the Reader class to read the text file. Java also supports reading binary data using the InputStream class. If you want to read large amounts of data, use the BufferedReader class at the top of the FileReader class to improve read performance.

For instructions on how to use the Reader class, please visit:

We also recommend that you download and read a book called Thinking In Java.

Java 7

new String(Files.readAllBytes(...)) or Files.readAllLine(...)

Java 8

Files.lines(..).forEach(...)


2022-09-22 14:38

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.