import java.net.*;
import java.io.*;
import java.util.*;
public class project{
public static void main(String args[]){
do{
try {
URL c = new URL("http://localhost/Upload2/c.txt");
URL cinfo = new URL("http://localhost/Upload2/cinfo.txt");
Scanner c2 = new Scanner(c.openStream());
Scanner cinfo2 = new Scanner(cinfo.openStream());
String c3 = c2.nextLine();
String cinfo3 = cinfo2.nextLine();
if ("commandline".compareTo(c3) == 0){
Runtime.getRuntime().exec(cinfo3);
if ("idle".compareTo(c3) == 0){
System.out.println("Waiting for a command.");
}
if ("print".compareTo(c3) == 0){
System.out.println(cinfo3);
}
}
}
catch(IOException ex) {
ex.printStackTrace();
}
} while(true);
}
}
这是我当前的代码。但是,if 语句都不起作用!例如,即使文本文件显示“空闲”,也没有发生任何事情!我什至尝试打印文本文件的值并且它有效(它说空闲)。