Android. Reading content from file
<p>I'm using the next method to read content from a file. The problem here is that i'm limited to ht unmber of characters specified for <code>inputBuffer</code> (in this case 1024). </p>

<p>First of all, if the content is less than 1024 chars long, i get a lot of whitespace chars, and i need to use trim to remove them.</p>

<p>Second of all, and this is more important, I'd like to read the entire content of the file, even if it is more than 1024 characters and insert it into a <code>String</code> object. I've understood that I should not use the <code>.available</code> method to determine if there is more data in the file, because it's not accurate or something like that.</p>

<p>Any ideas on how I should go about doing this?</p>

<pre><code>public String getContent( String sFileName )
{
    //Stop in case the file does not exists
    if ( !this.exists( sFileName ) )
        return null;

    FileInputStream fIn = null;

    InputStreamReader isr = null;

    String data = null;

    try{

        char[] inputBuffer = new char[1024];

        fIn = _context.openFileInput(sFileName);

        isr = new InputStreamReader(fIn);

        isr.read(inputBuffer);

        data = new String(inputBuffer);

        isr.close();

        fIn.close();

    }catch(IOException e){

        e.printStackTrace(System.err);
        return null;

    }

    return data.trim();
}
</code></pre>
