Hi Andre,
here is some code which runs on Windows XP unfortuately I don't have unix or linix so cannot test it on that, but theoretically you should just be able to replace the "cmd /c dir" with "ls -u afile.txt" where afile.txt is the file you want the access time from.
Code:
package test;
import java.io.*;
public class TestExecute
{
/**
* @param args the command line arguments
*/
public static void main(String[] args)
{
try
{
Runtime rt = Runtime.getRuntime();
Process p = rt.exec("cmd /c dir");
InputStream in = p.getInputStream();
OutputStream out = p.getOutputStream();
InputStream err = p.getErrorStream();
int intread = in.read();
char x;
while(intread!=-1)
{
x = (char)intread;
System.out.print( x + "");
intread = in.read();
}
}catch(Exception exc){/*handle exception*/}
}
}
Hope this helps.
Graham
Bookmarks