why does this give me an error? 
	 
	
		| Author | 
		Message | 
	 
		 
		Genisis
 
 
 
    
		 | 
		
		
			
				  Posted: Sun Apr 23, 2006 1:17 am    Post subject: why does this give me an error?  | 
	
				
				 | 
			 
			 
				
  | 
			 
			
				im trying to read one letter form a data file and it gives me the error at 
 
"alpha.read (char lettersguessed [x], 0, 25);"
 
 
[code]// The "Guessing" class.
 
import java.awt.*;
 
import hsa.Console;
 
import java.io.*;
 
 
public class Guessing
 
{
 
    static Console c;              // The output console
 
 
    public static void main (String [] args) throws IOException
 
    {
 
        c = new Console ();
 
        // declares variables and data files
 
        BufferedReader input = new BufferedReader (new FileReader ("word.txt"));
 
        int sets = 1, ran, many, wrong = 0, fcount = 0, temp2, choice = 0, tried = 0;
 
        String words [], temp, word;
 
        char gword, no = 'n', yes = 'y', fword [], guessed [], lettersguessed [];
 
        words = new String [sets];
 
 
 
        for (int x = 0 ; x < sets ; x++)
 
        {
 
            words [x] = input.readLine ();
 
        }
 
        input.close ();
 
 
        do
 
        {
 
            // selects a random word and finds its length and creates arrays
 
            ran = (int) (Math.random () * sets);
 
            word = words [ran];
 
            many = word.length ();
 
            fword = new char [many];
 
            guessed = new char [26];
 
            lettersguessed = new char [26];
 
            c.println ("What would you like to do? 1. Instructions 2. Game 3. Quit");
 
            choice = c.readInt ();
 
            c.clear ();
 
            switch (choice)
 
            {
 
                    // displays a set of instructions
 
                case 1:
 
                    {
 
                        break;
 
                    }
 
                    // starts the game
 
                case 2:
 
                    {
 
                        tried++;
 
                        // makes the word that they replace blank and same with the letters that they guess
 
 
                        BufferedReader alpha = new BufferedReader (new FileReader ("alphabet.txt"));
 
                        for (int x = 0 ; x < many ; x++)
 
                        {
 
                            fword [x] = '_';
 
                        }
 
                        for (int x = 0 ; x < 26 ; x++)
 
                        {
 
                            guessed [x] = ' ';
 
                            alpha.read (char lettersguessed [x], 0, 25);
 
                        }
 
                        alpha.close ();
 
                        do
 
                        {
 
                            // displays letters
 
                            c.setCursor (1, 14);
 
                            for (int x = 0 ; x < 26 ; x++)
 
                            {
 
                                c.print (lettersguessed [x] + " ");
 
                            }
 
                            c.println ("");
 
 
                            // tells them how many letters are in the word and display the amount with _'s
 
                            c.setCursor (2, 24);
 
                            c.println ("The word has " + many + " letters in it");
 
                            c.setCursor (3, (65 - many) / 2);
 
 
                            for (int y = 0 ; y < many ; y++)
 
                            {
 
                                c.print (fword [y] + " ");
 
                            }
 
                            c.println ("");
 
                            c.setCursor (4, 27);
 
 
                            c.println ("please guess a letter");
 
                            gword = c.getChar ();
 
 
                            // doesnt let them choose the same letter
 
 
                            for (int y = 0 ; y < 26 ; y++)
 
                            {
 
                                if (guessed [y] == gword)
 
                                {
 
                                    c.clear ();
 
                                    //if they have chosen this letter before then it will ask them
 
                                    //for a new letter
 
                                    do
 
                                    {
 
                                        c.setCursor (1, 22);
 
                                        c.println ("You already chose " + gword + ", choose agian");
 
                                        c.setCursor (3, (65 - many) / 2);
 
 
                                        for (int x = 0 ; x < many ; x++)
 
                                        {
 
                                            c.print (fword [x] + " ");
 
                                        }
 
                                        c.println ("");
 
                                        gword = c.getChar ();
 
                                        c.clear ();
 
                                    }
 
                                    while (guessed [y] == gword);
 
                                    y = 0;
 
 
                                }
 
                                else
 
                                {
 
                                    // if they havent chosen this letter it stores it into an array
 
                                    if (guessed [y] == ' ')
 
                                    {
 
                                        c.clear ();
 
                                        c.setCursor (3, (65 - many) / 2);
 
                                        for (int x = 0 ; x < many ; x++)
 
                                        {
 
                                            c.print (fword [x] + " ");
 
                                        }
 
                                        c.println ("");
 
                                        guessed [y] = gword;
 
                                        break;
 
                                    }
 
 
                                }
 
 
                            }
 
                            // tells the user that that letter is not in that word
 
                            if (word.indexOf (gword) < 0)
 
                            {
 
 
                                wrong++;
 
                                c.setCursor (2, 12);
 
                                c.println ("sorry but thats not in the word you have " + (6 - wrong) + " chances left");
 
                                try
 
                                {
 
                                    Thread.sleep (2500);
 
                                }
 
                                catch (InterruptedException e)
 
                                {
 
                                    System.out.println (e);
 
                                }
 
                                c.clear ();
 
 
                            }
 
                            else
 
                            {
 
                                if (word.indexOf (gword) >= 0)
 
                                {
 
                                    // replaces underscores with letters that were right
 
                                    for (int x = 0 ; x < many ; x++)
 
                                    {
 
                                        if (word.charAt (x) == gword)
 
                                        {
 
                                            fword [x] = gword;
 
                                        }
 
                                    }
 
 
                                    c.clear ();
 
                                }
 
                            }
 
                            // adds up the letters in the word
 
                            fcount = 0;
 
                            for (int a = 0 ; a < many ; a++)
 
                            {
 
                                if (fword [a] != '_')
 
                                {
 
                                    fcount++;
 
                                }
 
                            }
 
                            //if fcount they are the same as the number of letters
 
                            //in the random word then it will exit this loop
 
                            if (fcount / many >= 1)
 
                            {
 
                                break;
 
                            }
 
                            for (int x = 0 ; x < 26 ; x++)
 
                            {
 
 
                            }
 
 
                        }
 
                        while (wrong < 6);
 
 
 
                        c.clear ();
 
                        // tells them that they have guessed the word and tells them the word
 
                        if (fcount / many >= 1)
 
                        {
 
                            c.setCursor (1, 18);
 
                            c.println ("Congradulations you guessed the word!");
 
                        }
 
                        else
 
                            // tells them that the they havent got the word complete and tells them the word
 
                            {
 
                                c.println ("sorry but you lose the word was");
 
                            }
 
                        c.setCursor (2, (65 - many) / 2);
 
                        c.println (word);
 
 
                        try
 
                        {
 
                            Thread.sleep (2500);
 
                        }
 
                        catch (InterruptedException e)
 
                        {
 
                            System.out.println (e);
 
                        }
 
                        c.clear ();
 
 
                        // asks them if they would like to play the game agian
 
                        do
 
                        {
 
                            c.println ("would you like to try agian? y/n");
 
                            yes = c.getChar ();
 
 
                            // asks them if they are sure
 
                            if (yes == 'y' || yes == 'Y')
 
                            {
 
                                c.println ("are you sure you want to play agian? y/n");
 
                                no = c.getChar ();
 
                                c.clear ();
 
                            }
 
                            else
 
                            {
 
                                if (yes == 'n' || yes == 'N')
 
                                {
 
                                    c.println ("are you sure you want to quit? y/n");
 
                                    no = c.getChar ();
 
                                    c.clear ();
 
                                }
 
                            }
 
 
                        }
 
                        while (no == 'n' || no == 'N')
 
                            ;
 
                        // resets exit clauses
 
                        fcount = 0;
 
                        wrong = 0;
 
                        c.clear ();
 
                        break;
 
                    }
 
                    //quits the game
 
                case 3:
 
                    {
 
                        break;
 
                    }
 
            }
 
            if (choice == 3)
 
            {
 
                break;
 
            }
 
        }
 
 
        while (yes == 'y' || yes == 'Y')
 
            ;
 
        c.clear ();
 
        // thanks them for using the game
 
        if (tried > 0)
 
        {
 
            c.println ("Thank you for playing this guessing the word game");
 
        }
 
        else
 
        {
 
            c.println ("What? to good for the game?");
 
        }
 
 
    } // main method
 
} // Blahj class
 
 
[/code]
 
 
you'll need the data files so you dont get more errors so i attached them for who ever can help me thanks | 
			 
			
				 | 
			 
		  | 
	 
	 
		 | 
		
		 | 
	 
	  
		  | 
	 
		 
		Sponsor Sponsor 
		 
  
		 | 
		
 | 
	 
	 
		  | 
	 
				 
		 | 
	 
 
	
	
	 
	
	 |