Back
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
Yes, Guava provides this in the Resources class. For example:
URL url = Resources.getResource("foo.txt");String text = Resources.toString(url, Charsets.UTF_8);
URL url = Resources.getResource("foo.txt");
String text = Resources.toString(url, Charsets.UTF_8);
31k questions
32.8k answers
501 comments
693 users