Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (10.2k points)

Is there any utility that helps to read a text file in the resource into a String. I suppose this is a popular requirement, but I couldn't find any utility after Googling

1 Answer

0 votes
by (46k points)

Yes, Guava provides this in the Resources class. For example:

URL url = Resources.getResource("foo.txt");

String text = Resources.toString(url, Charsets.UTF_8);

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...