hi for my program i need to make two methods
one method will open the file passed in, create an array, and store the integers read from the file into the array. And the other method will display the contents of the array on scree and print 10 integers per line which will align numbers into columns of size 5.
for example if the file is called
6 <- first digit makes the size of the array
outcome should be
Enter input filename: numbers.txt
7 5 9 4 5 2
i don't know how to do the first part where i have to create an array and since i cant do the first part i don't know if my second part works or not.
public class Array
public static void main(String args) throws FileNotFoundException
Scanner keyboard = new Scanner(System.in);
System.out.print("Enter input filename: ");
String fileName = keyboard.nextLine();
File file = new File(fileName);
System.out.println("There is no input file called " + fileName);
public static int inputData(File file)
Scanner inputFile = new Scanner(file); // i don't know what to do on this part....
int number = inputFile.nextInt();
public static void printArray(int array)
int count = 0;
for (int ndx = 0; ndx < array.length; ndx++)
System.out.print(array[ndx] + " ");
if (count == 10)