Getting Time & Date
Can anyone have a look at this and tell me why it is not working - it only prints out the first try statement block to the console... :(
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
publicclass DateTime{
public DateTime()
{
}
publicstaticvoid main ( String [] args )
{
Runtime r = Runtime.getRuntime();
try{
Process p0 = r.exec(command0);
br =new BufferedReader(new InputStreamReader(p0.getInputStream()));
currentLine = br.readLine();
while(currentLine !=null){
System.out.println(currentLine);
currentLine = br.readLine() ;
}
}catch (IOException ioe){
ioe.printStackTrace();
}
try{
Process p1 = r.exec(command1);
br =new BufferedReader(new InputStreamReader(p1.getInputStream()));
currentLine = br.readLine();
while(currentLine !=null){
System.out.println(currentLine);
currentLine = br.readLine() ;
}
}catch (IOException ioe){
ioe.printStackTrace();
}
}
static String currentLine;
static BufferedReader br;
static String command0 ="cmd /C Time";
static String command1 ="cmd /C Date";
}

