Java Buffered Input Stream not reading
<p>I am having issues trying to figure out buffered input streams. We are having to create a text editor program in Java. I have a few examples from class as a guideline but still have not been able to figure it out. From my understanding I have primed the loop with a read, then it should read the entire file into the editor. I have typecasted the read as a char then set it to a string using .toString. Now it compiles, but freezes the program, so i must have an endless loop, but am unsure why.</p>

<pre><code>        //File open
    openItem.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
        JFileChooser jfc = new JFileChooser();
        jfc.setCurrentDirectory(new File("."));
        int result = jfc.showOpenDialog(null);
        if (result == JFileChooser.APPROVE_OPTION)
            {
            File selectedFile = jfc.getSelectedFile();
            BufferedInputStream bis = null;
            try
            {
                bis = new BufferedInputStream( new FileInputStream(selectedFile) );
                char inChar = (char)bis.read();
                while(inChar != -1)
                {
                //inChar = (char)bis.read();
                String charToString = Character.toString(inChar);
                textArea.setText(charToString);
                }
            }
            catch (Exception e2)
            {
                e2.printStackTrace();
            }
            }
        }
    });
</code></pre>