I think one could first detect the OS the the user is running, then call the native console clearing function for each OS. I have the OS detection, but I don't know how to call the native console clearing functions, please help.
public class Clear{
public static void main(String[] args){
if(isWindows()){
//Windows
}else if(isMac()){
//Mac
}else if(isLinux()){
//Linux
}else{
System.out.println("Your OS is not support!!");
}
}
public static boolean isWindows(){
String os = System.getProperty("os.name").toLowerCase();
return (os.indexOf("win") >= 0);
}
public static boolean isMac(){
String os = System.getProperty("os.name").toLowerCase();
return (os.indexOf("mac") >= 0);
}
public static boolean isUnix(){
String os = System.getProperty("os.name").toLowerCase();
return (os.indexOf("linux") >=0);
}
}
This post has been edited by macosxnerd101: 14 September 2010 - 06:51 PM
Reason for edit:: Added code tags. Please use them in the future.

New Topic/Question
Reply




MultiQuote










|