title: How to test file IO in Android unitTest/AndroidTest
body: <p>I am working on improving code coverage of my project and since there is a method I wrote to write file into android <code>internalStorage</code> by using the following code snippet from Android Developer website. </p>
  
  <pre><code>String FILENAME = "hello_file";
  String string = "hello world!";
  File testFile = new File(context.getFilesDir(), FILENAME);
  FileOutputStream fos =new FileOutputStream(file);
  fos.write(string.getBytes());
  fos.close();
  </code></pre>
  
  <p>My idea is to assert by reading the file and compare with <code>hello world!</code> and see if they matches to prove that my writing function works in unit test/ Android Instrumentation test. However, it not really straightforward for me to test this because of following </p>
  
  <ol>
  <li>I don't know the path of the file from unit test aspect (JVM) </li>
  <li>Not from Android instrumentation test perspective either. </li>
  </ol>
  
  <p>What is the best practice to test this kind of IO functionality in Android? Should I even care about if the file had been created and put? Or I should simply just check if the <code>fos</code> from in not null?</p>
  
  <pre><code>FileOutputStream fos =new FileOutputStream(file);
  </code></pre>
  
  <p>Please kindly provide me the advices. Thanks. </p>