| 10 | import java.util.*; |
| 11 | |
| 12 | public class getSystemInfo extends Applet { |
| 13 | |
| 14 | public getSystemInfo() { |
| 15 | super(); |
| 16 | return; |
| 17 | } |
| 18 | |
| 19 | public static String getInfo() { |
| 20 | |
| 21 | String result = ""; |
| 22 | |
| 23 | // -- Processor -- // |
| 24 | try { |
| 25 | // System.out.println("Available processors (cores): "+Integer.toString(Runtime.getRuntime().availableProcessors())); |
| 26 | result += "Available processors (cores): "+Integer.toString(Runtime.getRuntime().availableProcessors())+"\n"; |
| 27 | } |
| 28 | catch (Exception exception) { |
| 29 | //result += "Exception while gathering processor info: "+exception; |
| 30 | result += "Exception while gathering processor info\n"; |
| 31 | } |
| 32 | |
| 33 | // -- Memory -- // |
| 34 | try { |
| 35 | long maximumMemory = Runtime.getRuntime().maxMemory(); |
| 36 | // System.out.println("Maximum memory (bytes): " + (maximumMemory == Long.MAX_VALUE ? "No maximum" : maximumMemory)); |
| 37 | result += "Maximum memory (bytes): " + (maximumMemory == Long.MAX_VALUE ? "No maximum" : maximumMemory)+"\n"; |
| 38 | // System.out.println("Free memory (bytes): " + Runtime.getRuntime().freeMemory()); |
| 39 | result += "Free memory (bytes): " + Runtime.getRuntime().freeMemory()+"\n"; |
| 40 | // System.out.println("Total memory (bytes): " + Runtime.getRuntime().totalMemory()); |
| 41 | result += "Total memory (bytes): " + Runtime.getRuntime().totalMemory()+"\n"; |
| 42 | } |
| 43 | catch (Exception exception) { |
| 44 | //result += "Exception while gathering memory info: "+exception; |
| 45 | result += "Exception while gathering memory info\n"; |
| 46 | } |
| 47 | |
| 48 | // -- Displays -- // |
| 49 | try { |
| 50 | GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); |
| 51 | // System.out.println("Default Screen: "+ge.getDefaultScreenDevice().getIDstring()); |
| 52 | result += "Default Screen: "+ge.getDefaultScreenDevice().getIDstring()+"\n"; |
| 53 | GraphicsDevice[] gs = ge.getScreenDevices(); |
| 54 | for (int i=0; i<gs.length; i++) { |
| 55 | DisplayMode dm = gs[i].getDisplayMode(); |
| 56 | // System.out.println(gs[i].getIDstring()+" Mode: "+Integer.toString(dm.getWidth())+"x"+Integer.toString(dm.getHeight())+" "+Integer.toString(dm.getBitDepth())+"bit @ "+Integer.toString(dm.getRefreshRate())+"Hertz"); |
| 57 | result += gs[i].getIDstring()+" Mode: "+Integer.toString(dm.getWidth())+"x"+Integer.toString(dm.getHeight())+" "+Integer.toString(dm.getBitDepth())+"bit @ "+Integer.toString(dm.getRefreshRate())+"Hertz"+"\n"; |
| 58 | } |
| 59 | } |
| 60 | catch (Exception exception) { |
| 61 | //result += "Exception while gathering display info: "+exception; |
| 62 | result += "Exception while gathering display info\n"; |
| 63 | } |
| 64 | |
| 65 | // -- OS -- // |
| 66 | try { |
| 67 | // System.out.println("OS Name: "+System.getProperty("os.name")); |
| 68 | result += "OS Name: "+System.getProperty("os.name")+"\n"; |
| 69 | // System.out.println("OS Version: "+System.getProperty("os.version")); |
nothing calls this directly
no outgoing calls
no test coverage detected