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语句没有任何作用!例如,即使文本文件显示“闲置”,也没有任何事情发生!我甚至试图打印文本文件的值,它工作(它说闲置)。如果语句不能使用字符串
是的,你应该真的尝试使用正确的缩进。它使这些错误很容易被发现。编辑:对于那些需要*阅读*你的代码的人来说,这也很有礼貌,如果你对它进行了很好的格式化 - 我期望这就是为什么有人早些时候低估了你 – Jeff
对不起。 –