Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 18th, 2012  |  syntax: None  |  size: 0.66 KB  |  hits: 5  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Getting Computer Memory information in Java [closed]
  2. ProcessBuilder processBuilder = new ProcessBuilder("systeminfo");
  3. processBuilder.redirectErrorStream(true);
  4. Process process = processBuilder.start();
  5. String output = readOutput(process);
  6. try {
  7.     if (process.waitFor() != 0) {
  8.         throw new IOException(
  9.             "command exited in error: " + process.exitValue()
  10.                 + "n" + output);
  11.     }
  12. } catch (InterruptedException e) {
  13.     e.printStackTrace();
  14. }
  15.  
  16. // here parse output for what you want
  17.        
  18. Total Physical Memory: xxx MB
  19. Available Physical Memory: xxx MB
  20. Page File: Max Size: xxxx MB
  21. Page File: Available: xxxx MB
  22. Page File: In Use: xxx MB