我有一个非常大的输入集,我想给我试图调试的小型Java程序,但我对如何实现这一点感到迷茫。我的程序通过扫描仪读取System.in
读取数据在“项目属性”下的“运行”中给出命令行参数似乎不起作用。我给它"< testfile.in"它将它解释为args []中的两个值。我需要它将其解释为将文件读作System.in
编辑:我的代码
public static void main(String[] args) {
Scanner ifp = new Scanner(System.in);
int numCities = ifp.nextInt();
for(int c=0; c<numCities; c++){
int intersections = ifp.nextInt();
int streets = ifp.nextInt();
destination = intersections-1;
ArrayList<Edge> edges = new ArrayList<>();
ArrayList<Edge> negEdges = new ArrayList<>();
for(int i=0; i<streets; i++){
int start = ifp.nextInt();
int end = ifp.nextInt();
int distance = ifp.nextInt();
Edge temp = new Edge(start, end, distance);
edges.add(temp);
temp = new Edge(start, end, -distance);
negEdges.add(temp);
}
/* some shenanigans where I don't scan in anything */
}
}