Java exec executeDELETE(String parameters)

Here you can find the source of executeDELETE(String parameters)

Description

execute DELETE

License

Open Source License

Declaration

public static boolean executeDELETE(String parameters) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.File;

public class Main {
    public static final String ROOT = "user.dir";

    public static boolean executeDELETE(String parameters) {
        // TODO Auto-generated method stub
        boolean deleteStatus = false;
        try {//from   w w  w  .j  ava2 s  .  com
            File file = new File(executePWD() + File.separator + parameters);
            if (file.exists()) {
                deleteStatus = file.delete();
                System.out.println("is delete successful ? " + deleteStatus);
            } else {
                System.out.println(
                        ":::: File does not exist ::: File:: " + executePWD() + File.separator + parameters);
                deleteStatus = false;
            }
        } catch (Exception e) {
            System.out.println("Exception in execute delete command" + e.getMessage());
        }
        return deleteStatus;
    }

    public static String executePWD() {
        // TODO Auto-generated method stub
        String currentDirectory = null;
        try {
            currentDirectory = System.getProperty(ROOT);
        } catch (Exception e) {
            System.out.println("----Exception in PWD command execution -----" + e.getMessage());
        }
        return currentDirectory;
    }
}

Related

  1. executeCommandAndExtractStdOut(String cmd)
  2. executeCommandForceDir(String baseCommand, String osPath, File file)
  3. executeCommandLine(String command)
  4. executeCommandLineReturnAll( final String[] command)
  5. executeCommandLinux(final String _command)
  6. executeDotCommand(final File dotFile)
  7. executeGET(DataInputStream sockInp, DataOutputStream sockOutp)
  8. executeGetStatus(ProcessBuilder pb)
  9. executeIt(String command)