I am trying to import a web file containing a numbers that correspond to vertices for a graph. The first line states how many vertices there are. So i defined an int verticesAmount to correspond to how many vertices there are. After that I started a for loop to see catch the input of each line in the file and then put each number in an array by splitting them using the .split(" ") method. Everything up to this point compiles fine and when I print out the array I just made it prints out fine. However, when I try to cast each element of the array to an INT i get a compiler error and I cannot figure out why. Any help would be appreciated. Thank You.
import java.util.Scanner;
import java.io.*;
import java.util.ArrayList;
public class Graph {
public static void main(String[] args)throws Exception{
ArrayList<ArrayList<Integer>> array;
Scanner input2 = new Scanner(System.in);
System.out.println("Enter a URL");
String urlString = input2.next();
java.net.URL url = new java.net.URL(urlString);
Scanner input = new Scanner(url.openStream());
String verticesAmount = input.next();
int amount = Integer.parseInt(verticesAmount);
String[] stringArray = new String[10];
ArrayList<Integer> row = new ArrayList<Integer>();
String line;
for(int i = 0; i < amount; i++){
line = input.nextLine();
stringArray = line.split(" ");
for(int j = 0; j < stringArray.length; j++)
row.add(Integer.parseInt(stringArray[j]));