title: Android filewrite nullpointer exception
body: <p>In my app there are 3 EditTexts. I want to write the content of this EditTexts to a file, but the filewrite throws a nullpointer exception. Why?</p>
  
  <p><code>OutputStream f1;</code> is declared globally.</p>
  
  <pre><code>BtnSave = (Button)findViewById(R.id.Button01);
  BtnSave.setOnClickListener(new View.OnClickListener() {
      public void onClick(View v) {
          intoarray =   name + "|" + number + "|" + freq + "\n";
          Toast.makeText(Main.this, "" + intoarray, Toast.LENGTH_SHORT).show();
          //so far so good
            byte buf[] = intoarray.getBytes(); 
  
            try {
              f1 = new FileOutputStream("file2.txt");
          } catch (FileNotFoundException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          } 
            try {
              f1.write(buf);  //nullpointer exception
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          } 
            try {
              f1.close();
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          } 
      }
  </code></pre>