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 31 public final class Windows2000 implements CPUParser 32 { 33 private final int m_processors; 34 private final String m_cpuInfo; 35 36 public Windows2000() 37 { 38 int procs = 1; 39 String info = ""; 40 41 try 42 { 43 Runtime rt = Runtime.getRuntime(); 44 Process proc = rt.exec( "cmd.exe /C echo %NUMBER_OF_PROCESSORS%" ); 45 BufferedReader reader = new BufferedReader ( new InputStreamReader ( 46 proc.getInputStream() ) ); 47 String numProcs = reader.readLine(); 48 49 proc = rt.exec( "cmd.exe /C echo %PROCESSOR_IDENTIFIER%" ); 50 reader = new BufferedReader ( new InputStreamReader ( proc.getInputStream() ) ); 51 info = reader.readLine(); 52 53 procs = Integer.parseInt( numProcs ); 54 } 55 catch( Exception e ) 56 { 57 } 58 59 m_processors = procs; 60 m_cpuInfo = info; 61 } 62 63 66 public int numProcessors() 67 { 68 return m_processors; 69 } 70 71 77 public String cpuInfo() 78 { 79 return m_cpuInfo; 80 } 81 } 82 83 | Popular Tags |