View Single Post
Old Jun 1st, 2006, 10:43 PM   #4
Eric the Red
Hobbyist Programmer
 
Eric the Red's Avatar
 
Join Date: Feb 2006
Posts: 214
Rep Power: 0 Eric the Red is an unknown quantity at this point
Here's the code to read in the .txt file and store it in the string array from the above example

String temp = "";
            BufferedReader in = new BufferedReader (new FileReader ("PieceData1.txt"));

            while ((temp = in.readLine ()) != null)
            {
                fileCount = fileCount + 1;
            }
            in.close ();

            System.out.print ("Size of file is: " + fileCount);
           // size of file has been stored


            // use the size of the file to make an array of the specified to size of the file
            String fileData [] = new String [fileCount];
            in = new BufferedReader (new FileReader ("PieceData1.txt"));
            for (int i = 0 ; i < fileCount ; i++) //
            {
                fileData [i] = in.readLine ();
            }
            in.close ();
__________________
Death smiles at us all. All a man can do is smile back.
Eric the Red is offline   Reply With Quote