Want to read complete content of text file which has a max of 1MB size
<p>in JAVA i want to read the complete content of .log file which has a max of 1MB size and i need to store it in StringBuilder</p>

<p>I tried using this code, but giving exception STACKERRORFLOW.</p>

<pre><code>            String fileName = "C://test//.log";
    File testfile = new File(fileName);
    int ch;
    StringBuilder strcontent = new StringBuilder();
    try
    {
        FileInputStream fis = new FileInputStream(testfile);
        while((ch = fis.read()) != -1)
            strcontent.append((char)ch);
        fis.close();        
    }
            System.out.println(strcontent.toString());
</code></pre>

<p>What will be the problem in it.</p>
