I want to develop JSF page which can display the swap size if the operating system is Linux and what percentage is utilized. I found that this information can be read from /proc/swaps. But when I open it I get this
Filename Type Size Used Priority
/dev/sda2 partition 2047992 0 -1
How I can get just there values – 2047992 and 0? I know how to read the content of a text file. For example:
try {
BufferedReader in = new BufferedReader(new FileReader("infilename"));
String str;
while ((str = in.readLine()) != null) {
process(str);
}
in.close();
} catch (IOException e) {
}
And the other more advanced question is what if I have two swaps?
Regards
If you decide to parse the file, here is one implementation…