import java.io.*; import java.util.*; public class Topology { public static void readNeighbors(int myId, LinkedList<Integer> neighbors) { System.out.println("Reading topology"); try { Scanner sc = new Scanner(new FileReader("topology" + myId)); while (sc.hasNext()) { int neighbor = sc.nextInt(); neighbors.add(neighbor); } } catch (FileNotFoundException e) { System.err.println(e); } catch (IOException e) { System.err.println(e); } System.out.println(neighbors.toString()); } public static void main(String [] args) { LinkedList<Integer> l = new LinkedList<Integer>(); Topology.readNeighbors(Integer.parseInt(args[0]),l); } }