title: Android - Append Specfic Line In A Text File
body: <p>hey people,
  I have a text file which I need to append in my app.  Now I could rewrite the entire file incorporating the changes to a specific line but I'm hoping there is a more efficient solution.
  I know the line number I need to append however I'm unsure how to get to that line, preferably without looping through all of the others unless that is the only way.  This is what I have so far which recreates the entire file:`     </p>
  
  <pre><code>        try {
              FileOutputStream fOut = openFileOutput("tasklist.txt", MODE_APPEND);
              BufferedOutputStream buf = new BufferedOutputStream(fOut);
  
              OutputStreamWriter osw = new OutputStreamWriter(buf);
              BufferedWriter writer = new BufferedWriter(osw);
  
              for(int count = 0; count &lt; str.size(); count++)
              {
                  writer.write(str[count]);
                  writer.write("\r\n");
              }
  
              writer.flush();
              writer.close();
          } catch (Exception e) {
              e.printStackTrace();
              Toast.makeText(this, "Error saving txt file", Toast.LENGTH_SHORT);
          }`
  </code></pre>
  
  <p>Hopefully someone knows of a more efficient solution.  Thanks.</p>