PageRenderTime 17ms CodeModel.GetById 13ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/src/main/java/org/rrd4j/demo/Test.java

https://code.google.com/
Java | 36 lines | 25 code | 4 blank | 7 comment | 3 complexity | 36be8f8f56e0c01d8525ae1579505597 MD5 | raw file
 1package org.rrd4j.demo;
 2
 3import java.io.FileReader;
 4import java.io.BufferedReader;
 5import java.io.IOException;
 6
 7
 8class Test {
 9    /** Constant <code>LOADAVG_FILE="/proc/loadavg"</code> */
10    public static final String LOADAVG_FILE = "/proc/loadavg";
11
12    /**
13     * <p>main.</p>
14     *
15     * @param args an array of {@link java.lang.String} objects.
16     * @throws java.io.IOException if any.
17     */
18    public static void main(String[] args) throws IOException {
19        BufferedReader r = new BufferedReader(new FileReader(LOADAVG_FILE));
20        try {
21            String line = r.readLine();
22            if (line != null) {
23                String[] loads = line.split("\\s+");
24                if (loads.length >= 3) {
25                    String load = loads[0] + " " + loads[1] + " " + loads[2];
26                    System.out.println("LOAD = " + load);
27                    return;
28                }
29                System.out.println("Unexpected error while parsing file " + LOADAVG_FILE);
30            }
31        }
32        finally {
33            r.close();
34        }
35    }
36}