0

Possible Duplicate:
Whole text file to a String in Java

How can I read a text file to the very end?

Actually I need to output the whole file into the screen, therefore I think that I need to get the whole data in the file as an String.

Community
  • 1
  • 1
MBZ
  • 26,084
  • 47
  • 114
  • 191

1 Answers1

2

Use FileUtils's readFileToString() method.

String content = FileUtils.readFileToString(new File("file.txt"), "utf-8");
beerbajay
  • 19,652
  • 6
  • 58
  • 75