1 17 package org.apache.excalibur.util.system; 18 19 import java.io.BufferedReader ; 20 import java.io.InputStreamReader ; 21 22 import org.apache.excalibur.util.CPUParser; 23 24 30 public final class WindowsXP implements CPUParser 31 { 32 private final int m_processors; 33 private final String m_cpuInfo; 34 35 39 public WindowsXP() 40 { 41 int procs = 1; 42 String info = ""; 43 44 try 45 { 46 Runtime rt = Runtime.getRuntime(); 47 Process proc = rt.exec( "cmd.exe /C echo %NUMBER_OF_PROCESSORS%" ); 48 BufferedReader reader = new BufferedReader ( new InputStreamReader ( 49 proc.getInputStream() ) ); 50 String numProcs = reader.readLine(); 51 52 proc = rt.exec( "cmd.exe /C echo %PROCESSOR_IDENTIFIER%" ); 53 reader = new BufferedReader ( new InputStreamReader ( proc.getInputStream() ) ); 54 info = reader.readLine(); 55 56 procs = Integer.parseInt( numProcs ); 57 } 58 catch( Exception e ) 59 { 60 } 61 62 m_processors = procs; 63 m_cpuInfo = info; 64 } 65 66 69 public int numProcessors() 70 { 71 return m_processors; 72 } 73 74 80 public String cpuInfo() 81 { 82 return m_cpuInfo; 83 } 84 } 85 86 | Popular Tags |