Here you can find the source of findExe(String exeName, String... path)
Parameter | Description |
---|---|
exeName | an executable name (e.g., "mkfifo") |
path | a path (e.g., "/bin", "/usr/bin") |
Parameter | Description |
---|---|
DaemonException | an exception |
public static String findExe(String exeName, String... path)
//package com.java2s; // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell import java.io.File; public class Main { /**//from w w w .ja va 2 s . c o m * Find the executable with the given name by checking the directories * in the given path in order. * * @param exeName an executable name (e.g., "mkfifo") * @param path a path (e.g., "/bin", "/usr/bin") * @return full path to the executable, or null if the executable can't be found * @throws DaemonException */ public static String findExe(String exeName, String... path) { for (String dir : path) { File f = new File(dir + "/" + exeName); if (f.exists()) { // XXX: should check if it is executable return f.getPath(); } } return null; } }