From 9eeb4d8ada6c31845b83c218c2284d9436db6833 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Thu, 22 Jun 2006 02:57:23 +0000 Subject: [PATCH] move clearScreen method to Shell --- bindings/java/src/net/hyperic/sigar/cmd/Shell.java | 5 +++++ bindings/java/src/net/hyperic/sigar/cmd/Top.java | 4 +--- 2 files changed, 6 insertions(+), 3 deletions(-) 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));