Im new to Java and am trying to make a QuickUnion algorithm run. I have these text files on my desktop and want to program to read the integers in them. This is the end of the QuickUnion class.
public static void main(String[] args) {
int N = StdIn.readInt(); // Read number of sites
QuickUnionUF quickunion = new QuickUnionUF(N);
while (!StdIn.isEmpty()) {
int p = StdIn.readInt();
int q = StdIn.readInt(); // Read pair to connect
if (quickunion.connected(p, q)) continue; // Ignore if connected
quickunion.union(p, q); // Combine components
StdOut.println(p + " " + q); // and print connection
}
StdOut.println(quickunion.count() + " components");
}
My question is: how does StdIn work? How do I read the text file? the first test file contains two columns of numbers.