Languages
[Edit]
EN

Java read text from file (simple way)

3 points
Created by:
Maggotta
499

Solution 1

Edit

Output:

Solution 2

Edit

We can also read entire text file in just 1 line of code in java:

  • new String(Files.readAllBytes(path))

Output:

Solution 3

Edit

Output:

Input data

Edit

Input data preparation for examples in this article.

Java read text from file - input data
Java read text from file - input data

File path under Windows operating system:

File content:

See also

Edit
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join