How to prevent android app from crashing when a file has not been found using openFileInput
<p>I want to react to a situation that no file has been found using FileInputStream. When i ran an app that loads a file that doesn't exist it opens an android popup with force close. I would like to react to the situation by changing a text in a text view and saying that the file has not been found. i tried changing the exceptions to change a text view and show that a file has not been found and the app still crashes.</p>

<p>Here is the piece of code:</p>

<pre><code> FileInputStream fis = null;
    String collected = null;
    try {
        fis = openFileInput("test");
        byte[] dataArray = new byte[fis.available()];
        while (fis.read(dataArray) != -1){
            collected = new String(dataArray);
        }
    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block

        e.printStackTrace();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }finally{
        try {
            fis.close();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }


    tv.setText(collected);
</code></pre>
