你可以用以下实现
String cmd="cmd";
if(!System.getProperty("os.name").equals("Windows NT"))
cmd="command";
try{Runtim.getRuntime().exec(cmd+" /c del a.txt");}
catch(Exception e){}

解决方案 »

  1.   

    对!Runtime.getRuntime().exec()
      

  2.   

    我试了好像不行!如下:
    public class t
    {
    public static void main( String args[] )
    {
    String cmd="cmd";
    if(!System.getProperty("os.name").equals("Windows NT"))
    cmd="command";
    try{Runtime.getRuntime().exec(cmd+" /c del a.txt");}
    catch(Exception e){} }
    }
      

  3.   

    你是用的Win2000吧,
    public class TestDelFile
    {
    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!");} }
    }
    这样是可以的啊