How Windows uses the java process to obtain operating system disk and memory information
This article is about how Windows uses the java process to obtain operating system disk and memory information. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Memory: first create a table, and then call the operating system command to obtain memory capacity and other information
Create table os_meminfo (info VARCHAR2 (4000))
/
Create or replace and compile java source named syscmd as
Import java.io.*
Import java.lang.*
Import oracle.sql.*
Import java.io.BufferedInputStream
Import java.io.BufferedReader
Import java.io.InputStreamReader
Public class syscmd extends Object {
Public static void runcmd (int bufSize, String command, String result []) {
/ / String result
String returnResult
Int I = 0
Try {
Process p
P = Runtime.getRuntime () .exec (command)
/ / BufferedInputStream bis=new BufferedInputStream (p.getInputStream (), bufSize)
/ / byte buffer [] = new byte [bufSize]
BufferedInputStream in = new BufferedInputStream (p.getInputStream ())
BufferedReader inBr = new BufferedReader (new InputStreamReader (in))
String lineStr
While ((lineStr = inBr.readLine ())! = null) {
/ / System.out.println (lineStr)
If (lineStr.indexOf (memory) > 0) {
System.out.println (lineStr)
# sql {insert into os_meminfo (info) values (: lineStr)}
}
}
/ / while (bis.read (buffer,0,bufSize)! =-1)
/ / System.out.write (buffer,0,len)
P.waitFor ()
/ / for (int I = 0; I