title: Limit Android Filesize
body: <p><strong>Background</strong></p>
  
  <p>I'm keeping a relatively large text file in android storage, and appending to it periodically- while limiting the file's size to some arbitrary size (say 2MB)</p>
  
  <p>Hopefully I'm missing a function somewhere, or hopefully there is a better way to do this process.</p>
  
  <p>Currently, when the file <code>a</code> goes over that arbitrary size, I create a temporary file <code>b</code>, copy the relevant portion of the file <code>a</code> (more or less the substring of the file <code>a</code> starting at byte xxx where xxx is the number of bytes too large the file <code>a</code> would be if I wrote the next bit of data to the log) plus the current data, then overwrite the file <code>a</code> with the second file <code>b</code>.</p>
  
  <p>This is obviously terribly inefficient... </p>
  
  <p>Another solution that I'm not terribly fond of is to keep two files, and toggle between the two of them, clearing the next when the current is full, and switching to that file for output.</p>
  
  <p>However, it would be suuuuuper handy if I could just do something like this</p>
  
  <pre><code>File A = new File("output");
  A.chip(500);
  </code></pre>
  
  <p>or maybe</p>
  
  <pre><code>A.subfile(500,A.length()-500);
  </code></pre>
  
  <p><strong>TLDR;</strong></p>
  
  <p>Is there a function or perhaps library available for Android that can remove a portion of a file?</p>