-2

Im finding a lot of complicated answers however, I know there is a simple way and Im just not fitting it together.

I want the txt file to be put into the String txtString. inFS is for later parsing. What do I need to put the txt file to the string txtString?

My code:

fileByteStream = new FileInputStream("mytextfile.txt");
inFS = new Scanner(fileByteStream);         
txtString = ??
Jonny Henly
  • 4,023
  • 4
  • 26
  • 43
ANC2017
  • 1
  • 1
  • 7

1 Answers1

3
    String content = new String(Files.readAllBytes(Paths.get("mytextfile.txt")));

works with java7

mc20
  • 1,145
  • 1
  • 10
  • 26