public static void main( String args[] )
{
String cmd="cmd";
if(System.getProperty("os.name").equals("Windows 98")){
System.out.println("Your OS is Win98");
cmd="command";
}
try{Runtime.getRuntime().exec(cmd + " /c del c:\\a\\abcdefg.txt");}
catch(Exception e){System.out.println(" Error of Deleting File!");} }
{
String cmd="cmd";
if(System.getProperty("os.name").equals("Windows 98")){
System.out.println("Your OS is Win98");
cmd="command";
}
try{Runtime.getRuntime().exec(cmd + " /c del c:\\a\\abcdefg.txt");}
catch(Exception e){System.out.println(" Error of Deleting File!");} }
f.delete();
不过路径要是绝对路径!
{
File a=new File("c:\\c.txt");
a.delete();
}
catch(Exception)
{}
调用 你文件对象的delete()就可以了!
都说的这么详细..
不过,1楼的方法也可以