Code: Select all
System.out.print("\033[H\033[2J");
System.out.flush();
Wenn ich jedoch versuche, es mit Dr. Java auszuführen, funktioniert es nicht. Ich glaube nicht, dass Dr. Java ANSI-Escape-Codes unterstützt. Ich bin mir auch fast 100 % sicher, dass Dr. Java nicht auf UNIX basiert.
Ich konnte Dr. Java auch nicht dazu bringen, diese Option korrekt auszuführen:
Code: Select all
import java.io.IOException;
public class CLS {
public static void main(String... arg) throws IOException, InterruptedException {
new ProcessBuilder("cmd", "/c", "cls").inheritIO().start().waitFor();
}
}
Code: Select all
import java.io.IOException;
public class CLS {
public static void main(String[] arg) throws IOException, InterruptedException {
clearConsole();
}
public static void clearConsole() throws Exception {
String os = System.getProperty("os.name").toLowerCase();
if (os.contains("windows")) {
new ProcessBuilder("cmd", "/c", "cls").inheritIO().start().waitFor();
} else {
new ProcessBuilder("clear").inheritIO().start().waitFor();
}
}
}
Code: Select all
2 errors found:
[line: 12]
Error: The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class files
[line: 12]
Error: The method contains(java.lang.CharSequence) from the type java.lang.String refers to the missing type java.lang.CharSequence
Mobile version