title: Check to see if directory/file exist before creating?
body: <p>Currently this is my code:</p>
  
  <pre><code>    private void writeToSDFile(){
  
          File root = android.os.Environment.getExternalStorageDirectory(); 
          File dir = new File (root.getAbsolutePath() + "/download");
          dir.mkdirs();
          File file = new File(dir, "myData.txt");
  
  
          try {
              FileOutputStream f = new FileOutputStream(file);
              PrintWriter pw = new PrintWriter(f);
              pw.println(d8 + d7 + ":" + d6 + d5 + ":" + d4 + d3 + ":" + d2 + d1);
              pw.flush();
              pw.close();
              f.close();
          } catch (FileNotFoundException e) {
              e.printStackTrace();
              Log.i(TAG, "******* File not found. Did you" +
                      " add a WRITE_EXTERNAL_STORAGE permission to the manifest?");
          } catch (IOException e) {
              e.printStackTrace();
          }   
      }
  </code></pre>
  
  <p>Basically, I would like to know if there's a way (maybe by the use of an if statement) to only create the file/directory if they DONT exist. At the moment, it recreates them both each time writetoSDCard() is called. </p>
  
  <p>All I want to do is keep appending the data to the end of the file. Just for reference it'd  be stored like this: 00:00:00:00</p>
  
  <p>Thanks :)</p>
  
  <p>Also, while I'm here, just a quick question, is there a way for the program to say, read a list of 2 digit numbers from a txt document, then add them together? eg
  20
  20
  30
  So result on screen is 70? I haven't really found anything like this around  :/</p>