My input file has 84 integers and I'm not sure what I'm doing wrong.
PLEASE HELP!

import java.util.*;
import javax.swing.*;
import java.awt.*;
import java.util.Scanner;
import java.io.*;


public class Museum
{
    private int Week=3;
    private int Hour=4;
    private int Day=7;

    int[][][] visitors = new int[Week][Day][Hour];
    private int[] allWeeks;
    private int[] allHours;
    private int[] allDays;
    Scanner scanToken;
    String line;
    Scanner scan = new Scanner(new File("Museum_Duguay.txt"));

    public Museum() throws IOException
    {
        line = scan.nextLine();
        scanToken = new Scanner(line);

        for(int a=0; a < Week; a++)
            {
                for(int b = 0; b < Day; b++)
                  {
                      for(int c=0; c < Hour; c++)
                      {
                    visitors[a][b][c] = scanToken.nextInt();
                }
}
}
}

it highlights "visitors[a][b][c] = scanToken.nextInt();" when the error occurs when i try to run it.

That's because scanToken = new Scanner(line); creates a new Scanner object based on the String, line, that you passed as the argument. Obviously, since line is a String, it is not an integer, and trying to read ints from it will not succeed. The first declaration of Scanner that you did Scanner scan = new Scanner(new File("Museum_Duguay.txt")); was the correct way to do it. Now all you need to do is use the nextInt() method to get the Integers from that file.

commented: I haven't given you rep in a while and you've had a lot of good posts lately. :) +15
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.