Java exec executeCommandForceDir(String baseCommand, String osPath, File file)

Here you can find the source of executeCommandForceDir(String baseCommand, String osPath, File file)

Description

execute Command Force Dir

License

Apache License

Declaration

private static void executeCommandForceDir(String baseCommand, String osPath, File file) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.File;
import java.io.IOException;

public class Main {
    private static void executeCommandForceDir(String baseCommand, String osPath, File file) {
        String forceDirectoryPath = osPath;
        if (file.isFile())
            try {
                forceDirectoryPath = file.getParentFile().getCanonicalPath();
            } catch (IOException ex) {
                ex.printStackTrace();/*from  ww  w .  j  a  v  a 2 s . com*/
            }
        String args[] = { baseCommand, forceDirectoryPath };
        try {
            Runtime.getRuntime().exec(args);
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
}

Related

  1. executeCommand(String command, boolean waitForResponse)
  2. executeCommand(String[] command, boolean wait)
  3. executeCommand1(boolean isProcessBuilder, String command)
  4. executeCommand2(boolean isProcessBuilder, String command)
  5. executeCommandAndExtractStdOut(String cmd)
  6. executeCommandLine(String command)
  7. executeCommandLineReturnAll( final String[] command)
  8. executeCommandLinux(final String _command)
  9. executeDELETE(String parameters)