Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Proc Info[Complete, error Free]
07-28-2010, 11:17 AM
Post: #1
Proc Info[Complete, error Free]
This is for *nix only, only because I didn't bother to do a windows check. But if using on windows, replace ps -aux with tasklist!

Code:
import java.io.*;
import java.util.Calendar;
import java.text.SimpleDateFormat;
public class Proc{

    public static void main(String[] args)throws IOException{
        String  P = "";
        FileWriter NWrite = new FileWriter(CurTime()+"--Proc.txt");
            BufferedWriter Write = new BufferedWriter(NWrite);
            Process proc = Runtime.getRuntime().exec("ps -aux");
            BufferedReader In = new BufferedReader(new InputStreamReader(proc.getInputStream()));
            while((P = In.readLine()) != null){
            Write.write(P +"\n");        
            }
            Write.close();
    }
    
    public static String CurTime(){
    Calendar CNow = Calendar.getInstance();
        SimpleDateFormat DNow = new SimpleDateFormat("yyyy-MM-dd-hh.mm.ss");
        return DNow.format(CNow.getTime());
    }
    
}

"Character is determined more by the lack of certain experiences than by those one has had."
Friedrich Nietzsche
Visit this user's website Find all posts by this user
Quote this message in a reply
07-28-2010, 04:00 PM
Post: #2
RE: Proc Info[Complete, error Free]
nix systems own
Visit this user's website Find all posts by this user
Quote this message in a reply
07-28-2010, 05:23 PM
Post: #3
RE: Proc Info[Complete, error Free]
(07-28-2010 04:00 PM)codecaine Wrote:  nix systems own

Big Grin absolutely agreed

"Character is determined more by the lack of certain experiences than by those one has had."
Friedrich Nietzsche
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


 Quick Theme: