Runtime.getruntime.exec( “CLS /清除”);不能在Windows中清除控制台

时间:2015-07-09 07:54:25

标签: java console

我已多次尝试清除控制台并编写此 Runtime.getruntime.exec(“cls”); 但未获得任何结果,表示控制台未被清除

1 个答案:

答案 0 :(得分:0)

\b可能会成功。每个字符打印一个System.out.print("Foo"); System.out.print("\b\b\b"); System.out.print("Bar");

String foo = "Foo";
System.out.print(foo);
for (int i = 0; i < foo.length(); i++) {
    System.out.print("\b");
}
System.out.print("Bar");

打印“Bar”

var server = http.createServer(function(request, response){
    console.log('Connection');
    var path = url.parse(request.url).pathname;
    switch(path){
        case '/':
            response.writeHead(200, {'Content-Type': 'text/html'});
            response.write('hello world', function(err) { response.end(); });
            break;
        case '/index.html': 
            fs.readFile(__dirname + path, function(error, data){
                if (error){
                    response.writeHead(404);
                    response.write("opps this doesn't exist - 404");
                }
                else{
                    response.writeHead(200, {"Content-Type": "text/html"});
                    response.write(data, function(err) { response.end(); });
                }
            });
            break;
        default:
            response.writeHead(404);
            response.write("opps this doesn't exist - 404", function(err) { response.end(); });
            break;
    }
});

使用循环的结果相同。