title: Reading a text file to a string ALWAYS results in empty string?
body: <p>For the record, I know that reading the text file to a string does not ALWAYS result in an empty string, but in my situation, I can't get it to do anything else.</p>
  
  <p>I'm currently trying to write a program that reads text from a .txt file, manipulates it based on certain arguments, and then saves the text back into the document. No matter how many different ways I've tried, I can't seem to actually get text from .txt file. The string just returns as an empty string.</p>
  
  <p>For example, I pass in the arguments "-c 3 file1.txt" and parse the arguments for the file (the file is always passed in last). I get the file with:</p>
  
  <pre><code>            File inputFile = new File(args[args.length - 1]);
  </code></pre>
  
  <p>When I debug the code, it seems to recognize the file as file1.txt and if I pass in the name of a different file, which doesn't exist, and error is thrown. So it is correctly recognizing this file. From here I have attempted every type of file text parsing I can find online, from old Java version techniques up to Java 8 techniques. None have worked. A few I've tried are:</p>
  
  <pre><code>String fileText = "";
          try {
              Scanner input = new Scanner(inputFile);
              while (input.hasNextLine()) {
                  fileText = input.nextLine();
                  System.out.println(fileText);
              }
              input.close();
          } catch (FileNotFoundException e) {
              usage();
          }
  </code></pre>
  
  <p>or</p>
  
  <pre><code>String fileText = null;
      try {
          fileText = new String(Files.readAllBytes(Paths.get(filename)), StandardCharsets.UTF_8);
      } catch (IOException e) {
          e.printStackTrace();
      }
  </code></pre>
  
  <p>I've tried others too. Buffered readers, scanners, etc. I've tried recompiling the project, I've tried 3rd party libraries. Still just getting an empty string. I'm thinking it must be some sort of configuration issue, but I am stumped.</p>
  
  <p>For anyone wondering, the file seems to be in the correct place, when I reference the wrong location an exception is thrown. And the file DOES in fact have text in it. I've quadruple checked.</p>