title: how to check if something has been written into file?
body: <p>I have a rather tricky question</p>
  
  <p>Is there a way to check if something has been written into a file?</p>
  
  <hr>
  
  <p>This is a piece of code written by <a href="https://stackoverflow.com/users/65070/eric-petroelje">Eric Petroelje</a>, and I need to check if the "Hello world" has been written into a file.</p>
  
  <p>This would be useful for checking if a big number is written to a text file.
  Thank you in advance!</p>
  
  <pre><code>public class Program {
      public static void main(String[] args) {
          String text = "Hello world";
          BufferedWriter output = null;
          try {
              File file = new File("example.txt");
              output = new BufferedWriter(new FileWriter(file));
              output.write(text);
          } catch ( IOException e ) {
              e.printStackTrace();
          } finally {
            if ( output != null ) {
              output.close();
            }
          }
      }
  }
  </code></pre>