Q:

How would I convert a txt file containing a lot of symbols into a array?

so I just have a quick question. The program is supposed to create a character array, and get the content from a text file, containing a lot of random symbols like &,?,!,letters, and numbers. I am not allowed to create seperate arrays, and put them into the 2d array instead. How would I go about doing so? I already know the number of rows and columns because it tells me at the top of the file before actually having all the symbols and stuff. Heres what I have so far:
    char [][]charArray=new char[a][b];
    for(int z=0;z<charArray.length;z++)
    {
        for(int y=0;y<charArray[y].length;y++)
        {
            charArray[y]=fileReader.next();

        }
    }

So A is the number of rows, and B is the number of columns to read from. When I run the program, it says that it is expecting a char []charArray, and it found a string, and the error is called an incompatible type error.
ALso ps: fileReader is my scanner to read from a file. THanks!

A:

First of all, you need to use more descriptive names for your variables. For example, why name the variable a when a really represents the number of rows in the file? Instead, use numRows (and likewise for b, use numCols). Also, you really should name your scanner scanner. There is a FileReader class and your fileReader variable name is misleading---it makes everyone think you're using a FileReader instead of a Scanner. Finally, the brackets used to declare an array type in Java are normally placed adjacent to the type name, as in char[][] instead of char [][]. This does not change the way the code executes, but it conforms better to common convention.
Now, to your problem. You stated that the number of rows/columns are declared at the beginning of the file. This solution assumes the file does in fact contain numRows rows and numCols columns. Basically, next returns a String. You can use String.toCharArray to convert the String to a char[]. Then you simply copy the characters to the appropriate position in your charArray.
    Scanner scanner = new Scanner(theFile);

    char[][] charArray=new char[numRows][numCols];

    for (int i = 0; i < numRows; i++) {

        final char[] aLine = scanner.next().toCharArray();
        for(int j = 0; j < aLine.length;j++){
            charArray[i][j] = aLine[j];
        }

    }       

