1 2 Previous Next 19 Replies Latest reply: Apr 24, 2008 1:38 PM by 807601 RSS

    I am trying to read in a .txt file, but I have a FileNotFound Exception

    807601
      So I am trying to read in as5.txt. It is located in the Assignment5 folder. I probably just have the syntax wrong, but can someone help me?
      import java.util.Scanner;
      import javax.swing.JFrame;
      import java.awt.Color;
      import java.io.*;
      
      public class Driver {
           public static void main(String [] args){
                
                JFrame window = new JFrame ("Window");//This creates the window
                window.setBounds(30, 100, 700, 700);
                window.setVisible(true);
                window.setLayout(null);
                
                FileReader as5 = new FileReader("Assignment5.as5.txt");
                Scanner file = new Scanner(as5);
                GameSquare square = new GameSquare(window, 0, 0);
                GameSquare[][] board = new GameSquare[8][8];
                int x = 0;
                int y = 0;
                for(int i=0;i < 8; i++){
                     for(int j=0;j < 8; j++){
                          board[i][j] = new GameSquare(window, x, y);
                          x=x+80;
                          
                     }
                     x=0;
                     y=y+80;
                }
           }
      }
        1 2 Previous Next