Check this article our for reading from a file.
Then, you can use Java's Scanner class to read individual items and put them into a list.
For example:
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
import java.util.ArrayList;
public class ReadFromFile {
public static void main(String[] args) {
File file = new File("file-name.txt");
try {
Scanner scanner = new Scanner(file);
List<Integer> myIntList = new ArrayList<>();
while (scanner.hasNext()) {
int i = scanner.nextInt();
myIntList.add(i);
}
scanner.close();
// now you have an ArrayList with the numbers in it that you can use
}
catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}