title: Android FileInputStream read() txt file to String
body: <p>Any experts available to help me? In my Android main activity, I'm trying to save a String to a file and then retrieve it if the user has set it before. Wasn't able to find any examples close to what I am doing. I would most appreciate any help! Here is my test case that crashes:</p>
  
  <pre><code>String testString = "WORKS";
  String readString;
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
  
      FileOutputStream fos;
  
      try {
          fos = openFileOutput("test.txt", Context.MODE_PRIVATE);
          fos.write(testString.getBytes());
          fos.close();
      } catch (FileNotFoundException e) {
          e.printStackTrace();
  
      } catch (IOException e) {
          e.printStackTrace();
  
      }
  
      File file = getBaseContext().getFileStreamPath("test.txt");
  
      if (file.exists()) {
  
          FileInputStream fis;
  
          try {
              fis = openFileInput("test.txt");
              fis.read(readString.getBytes());
              fis.close();
  
          } catch (IOException e) {
              e.printStackTrace();
  
          } 
  
          txtDate.setText(String.valueOf(readString));
  
         } else {
                       // more code
         }
       }
   }
  </code></pre>