Command to find the number of processes running in a PC
For eg:-, if I need to find the number of postgres processes running in my pc, just run the command,
ps -C postgres | wc -l
Thursday, April 7, 2011
Monday, April 4, 2011
JSP program to write current date and time to a text file
String str;
java.util.Date currentDate = new java.util.Date(); //gets the current date
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
str = sdf.format(currentDate);
String nameOfTextFile =getServletContext().getRealPath("imp.txt");
try
{
PrintWriter pw = new PrintWriter(new FileOutputStream(nameOfTextFile));
pw.println(str);
//clean up
pw.close();
}
catch(IOException e)
{
out.println(e.getMessage());
}
java.util.Date currentDate = new java.util.Date(); //gets the current date
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
str = sdf.format(currentDate);
String nameOfTextFile =getServletContext().getRealPath("imp.txt");
try
{
PrintWriter pw = new PrintWriter(new FileOutputStream(nameOfTextFile));
pw.println(str);
//clean up
pw.close();
}
catch(IOException e)
{
out.println(e.getMessage());
}
Subscribe to:
Posts (Atom)