diff --git a/bindings/java/src/net/hyperic/sigar/cmd/Shell.java b/bindings/java/src/net/hyperic/sigar/cmd/Shell.java index 094637ef..215fbacd 100644 --- a/bindings/java/src/net/hyperic/sigar/cmd/Shell.java +++ b/bindings/java/src/net/hyperic/sigar/cmd/Shell.java @@ -30,6 +30,7 @@ import net.hyperic.sigar.util.Getline; public class Shell extends ShellBase { public static final String RCFILE_NAME = ".sigar_shellrc"; + private static final String CLEAR_SCREEN = "\033[2J"; private Sigar sigar = new Sigar(); private SigarProxy proxy = SigarProxyCache.newInstance(this.sigar); @@ -39,6 +40,10 @@ public class Shell extends ShellBase { public Shell() { } + public static void clearScreen() { + System.out.print(CLEAR_SCREEN); + } + public SigarProxy getSigarProxy() { return this.proxy; } diff --git a/bindings/java/src/net/hyperic/sigar/cmd/Top.java b/bindings/java/src/net/hyperic/sigar/cmd/Top.java index a6590a2a..0be0a005 100644 --- a/bindings/java/src/net/hyperic/sigar/cmd/Top.java +++ b/bindings/java/src/net/hyperic/sigar/cmd/Top.java @@ -27,8 +27,6 @@ public class Top { private static final String HEADER = "PID\tUSER\tSTIME\tSIZE\tRSS\tSHARE\tSTATE\tTIME\t%CPU\tCOMMAND"; - private static final String CLEAR_SCREEN = "\033[2J"; - public static void main(String[] args) throws Exception { Sigar sigarImpl = new Sigar(); @@ -36,7 +34,7 @@ public class Top { SigarProxyCache.newInstance(sigarImpl, SLEEP_TIME); while (true) { - System.out.print(CLEAR_SCREEN); + Shell.clearScreen(); System.out.println(Uptime.getInfo(sigar));