how do i covert the line read in the file to "_"s?
<p>I'm trying to create a hangman program that uses file io/ file input. I want the user to choose a category (file) which contains 4 lines; each has one word. The program will then read the line and convert it into <code>_</code>s , this is what the user will see.
Where would I insert this --> 
{
  lineCount++;
  output.println (lineCount + "   " + line);
  line = input.readLine ();
}</p>

<p>/*</p>

<ul>
<li>Hangman.java </li>
<li>The program asks the user to choose a file that is provided. </li>
<li>The program will read one line from the file and the player will guess the word.</li>
<li>and then outputs the line, the word will appear using "_".</li>
<li>The player will guess letters within the word or guess entire word,</li>
<li>if the player guesses correctly the "_" will replaced with the letter guessed. </li>
<li>But, if the player guesses incorrectly the a part of the stickman's body will be added,</li>
<li>then the user will be asked to guess again. The user can also enter "!" to guess the entire word,</li>
<li>if  the guess correctly they win, but if they guess incorrectly they will be asked to guess again.</li>
<li>Once it has finished reading the file, the program outputs the number of guesses.</li>
</ul>

<p>*/</p>

<p>import java.awt.*;
import hsa.Console;</p>

<p>//class name
public class Hangman
{
    static Console c;</p>

<p>public static void main (String [] args)
  {
    c = new Console ();  </p>

<pre><code>PrintWriter output;
String fileName;
</code></pre>

<p>//ask user to choose file; file contains words for user to guess</p>

<p>c.println ("The categories are: cartoons.txt, animals.txt, and food.txt. Which category would you like to choose?");</p>

<pre><code>fileName = c.readLine ();    

// E:\\ICS\\ICS 3U1\\Assignments\\JavaFiles\\+fileName
</code></pre>

<p>try {</p>

<pre><code>        /*  Sets up a file reader to read the file passed on the command
           line one character at a time */
        FileReader input = new FileReader(args[0]);

        /* Filter FileReader through a Buffered read to read a line at a
           time */
        BufferedReader bufRead = new BufferedReader(input);

        String line;    // String that holds current file line
        int count = 0;  // Line number of count 

        // Read first line
       line = bufRead.readLine();
        count++;

        // Read through file one line at time. Print line # and line
       while (line != null){
           c.println(count+": "+line);
            line = bufRead.readLine ();
            count++;
       }

        bufRead.close();

    }
catch (FileNotFoundException e)
{
  c.println("File does not exist or could not be found.");
  c.println("FileNotFoundException: " + e.getMessage());
} 
catch (IOException e) 
{
  c.println("Problem reading file.");
  c.println("IOException: " + e.getMessage());
}
</code></pre>
