當前位置: 首頁>>代碼示例>>Java>>正文


Java File.canExecute方法代碼示例

本文整理匯總了Java中java.io.File.canExecute方法的典型用法代碼示例。如果您正苦於以下問題:Java File.canExecute方法的具體用法?Java File.canExecute怎麽用?Java File.canExecute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.io.File的用法示例。


在下文中一共展示了File.canExecute方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getFileStatus

import java.io.File; //導入方法依賴的package包/類
@Override
public FileStatus getFileStatus(Path path) throws IOException {
  File file = pathToFile(path);
  if (!file.exists()) {
    throw new FileNotFoundException("Can't find " + path);
  }
  // get close enough
  short mod = 0;
  if (file.canRead()) {
    mod |= 0444;
  }
  if (file.canWrite()) {
    mod |= 0200;
  }
  if (file.canExecute()) {
    mod |= 0111;
  }
  ShimLoader.getHadoopShims();
  return new FileStatus(file.length(), file.isDirectory(), 1, 1024,
          file.lastModified(), file.lastModified(),
          FsPermission.createImmutable(mod), "owen", "users", path);
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:23,代碼來源:TestUtil.java

示例2: getLameMode

import java.io.File; //導入方法依賴的package包/類
/**
         * This method is so-named because it only sets the owner privileges,
         * not any "group" or "other" privileges.
         * <P/>
         * This is because of Java limitation.
         * Incredibly, with Java 1.6, the API gives you the power to set
         * privileges for "other" (last nibble in file Mode), but no ability
         * to detect the same.
         */
        static protected String getLameMode(File file) {

            int umod = 0;

//#ifdef JAVA6
            if (file.canExecute()) {
                umod = 1;
            }

//#endif
            if (file.canWrite()) {
                umod += 2;
            }

            if (file.canRead()) {
                umod += 4;
            }

            return "0" + umod + "00";

            // Conservative since Java gives us no way to determine group or
            // other privileges on a file, and this file may contain passwords.
        }
 
開發者ID:s-store,項目名稱:sstore-soft,代碼行數:33,代碼來源:TarGenerator.java

示例3: writeMiniVPN

import java.io.File; //導入方法依賴的package包/類
private static String writeMiniVPN(Context context) {
    String[] abis;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) abis = getSupportedABIsLollipop();
    else
        //noinspection deprecation
        abis = new String[]{Build.CPU_ABI, Build.CPU_ABI2};
    String nativeAPI = NativeUtils.getNativeAPI();
    if (!nativeAPI.equals(abis[0])) {
        VpnStatus.logWarning(R.string.abi_mismatch, Arrays.toString(abis), nativeAPI);
        abis = new String[]{nativeAPI};
    }
    for (String abi : abis) {
        File vpnExecutable = new File(context.getCacheDir(), getMiniVPNExecutableName() + "." + abi);
        if ((vpnExecutable.exists() && vpnExecutable.canExecute()) || writeMiniVPNBinary(context, abi, vpnExecutable)) {
            return vpnExecutable.getPath();
        }
    }
    return null;
}
 
開發者ID:akashdeepsingh9988,項目名稱:Cybernet-VPN,代碼行數:20,代碼來源:VPNLaunchHelper.java

示例4: findExe

import java.io.File; //導入方法依賴的package包/類
private File findExe(Wizard installer, File path, String exe)
{
	for( String exeType : EXE_TYPES )
	{
		File exeFile = new File(path, exe + exeType);
		if( exeFile.canExecute() )
		{
			return exeFile;
		}
	}

	JOptionPane.showMessageDialog(installer.getFrame(),
		"The directory you have specified" + " does not contain the Libav program '" + exe
			+ "'.\nPlease select the" + " correct path, and try again.", "Incorrect LibAv Directory",
		JOptionPane.ERROR_MESSAGE);
	return null;
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:18,代碼來源:LibAvCallback.java

示例5: scanFile

import java.io.File; //導入方法依賴的package包/類
FileScanMetaData scanFile(File file) throws FileNotFoundException, IOException {
    if (!isNull(file) && file.canExecute()) {
        String fileName = file.getName();
        try (FileInputStream fileInputStream = new FileInputStream(file)) {
            return scanFile(fileName, fileInputStream);
        }
    } else {
        throw new InvalidFileException("A valid java.io.File is required");
    }
}
 
開發者ID:B-V-R,項目名稱:VirusTotal-public-and-private-API-2.0-implementation-in-pure-Java,代碼行數:11,代碼來源:Engine.java

示例6: Jexec

import java.io.File; //導入方法依賴的package包/類
Jexec() throws IOException {
    jexecCmd = new File(JAVA_LIB, "jexec");
    if (!jexecCmd.exists() || !jexecCmd.canExecute()) {
        throw new Error("jexec: does not exist or not executable");
    }

    testJar = new File("test.jar");
    StringBuilder tsrc = new StringBuilder();
    tsrc.append("public static void main(String... args) {\n");
    tsrc.append("   for (String x : args) {\n");
    tsrc.append("        System.out.println(x);\n");
    tsrc.append("   }\n");
    tsrc.append("}\n");
    createJar(testJar, tsrc.toString());
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:16,代碼來源:Jexec.java

示例7: findElfReader

import java.io.File; //導入方法依賴的package包/類
final String findElfReader() {
    String[] paths = {"/usr/sbin", "/usr/bin"};
    final String cmd = isSolaris ? "elfdump" : "readelf";
    for (String x : paths) {
        File p = new File(x);
        File e = new File(p, cmd);
        if (e.canExecute()) {
            return e.getAbsolutePath();
        }
    }
    System.err.println("Warning: no suitable elf reader!");
    return null;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:14,代碼來源:RunpathTest.java

示例8: getPathTo

import java.io.File; //導入方法依賴的package包/類
public static String getPathTo(String name) throws AssertionError {
    String path = System.getenv("Path");
    if (path == null)
        path = System.getenv("PATH");
    for (String dirname : path.split(File.pathSeparator)) {
        File file = new File(dirname, name);
        if (file.isFile() && file.canExecute()) {
            return file.getAbsolutePath();
        }
    }
    return null;
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:13,代碼來源:LaunchWebStartTest.java

示例9: init

import java.io.File; //導入方法依賴的package包/類
private void init(SystemProperties config) throws IOException {
    if (config != null && config.customSolcPath() != null) {
        solc = new File(config.customSolcPath());
        if (!solc.canExecute()) {
            throw new RuntimeException(String.format(
                    "Solidity compiler from config solc.path: %s is not a valid executable",
                    config.customSolcPath()
            ));
        }
    } else {
        initBundled();
    }
}
 
開發者ID:talentchain,項目名稱:talchain,代碼行數:14,代碼來源:Solc.java

示例10: init

import java.io.File; //導入方法依賴的package包/類
private void init(SystemProperties config) throws IOException {
    if (config != null && config.customSolcPath() != null) {
        solc = new File(config.customSolcPath());
        if (!solc.canExecute()) {
            throw new RuntimeException(String.format(
                    "Solidity compiler from config solc.path: %s is not a valid executable",
                    config.customSolcPath()
            ));
        }
    } else {
        throw new RuntimeException("No Solc version provided. Check if 'solc.path' config is set.");
    }
}
 
開發者ID:rsksmart,項目名稱:rskj,代碼行數:14,代碼來源:Solc.java

示例11: FileInfos

import java.io.File; //導入方法依賴的package包/類
public FileInfos(File f) {
	name = f.getName();
	if (name.isEmpty()) // Happens when 'f' is a root
		name = f.getPath();
	length = f.length();
	lastModified = f.lastModified();
	attributes = 0;
	if (f.isDirectory()) attributes |= BIT_ISDIRECTORY;
	if (f.isFile())      attributes |= BIT_ISFILE;
	if (f.isHidden())    attributes |= BIT_ISHIDDEN;
	if (f.canRead())     attributes |= BIT_CANREAD;
	if (f.canWrite())    attributes |= BIT_CANWRITE;
	if (f.canExecute())  attributes |= BIT_CANEXECUTE;
}
 
開發者ID:matthieu-labas,項目名稱:JRF,代碼行數:15,代碼來源:FileInfos.java

示例12: isExecutable

import java.io.File; //導入方法依賴的package包/類
public static boolean isExecutable(String strPath) throws JFCALCExpErrException {
    File f = getFileFromCurrentDir(strPath);
    try {
        return f.canExecute();
    } catch (Exception e) {
        throw new JFCALCExpErrException(ERRORTYPES.ERROR_CANNOT_ACCESS_FILE);
    }
}
 
開發者ID:woshiwpa,項目名稱:SmartMath,代碼行數:9,代碼來源:IOLib.java

示例13: findExe

import java.io.File; //導入方法依賴的package包/類
public static File findExe(File path, String exe)
{
	for( String exeType : EXE_TYPES )
	{
		File exeFile = new File(path, exe + exeType);
		if( exeFile.exists() && exeFile.canExecute() )
		{
			return exeFile;
		}
	}
	return null;
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:13,代碼來源:ExecUtils.java

示例14: getAjavaCmd

import java.io.File; //導入方法依賴的package包/類
static String getAjavaCmd(String cmdStr) {
    File binDir = new File(JavaHome, "bin");
    File unpack200File = IsWindows
            ? new File(binDir, cmdStr + ".exe")
            : new File(binDir, cmdStr);

    String cmd = unpack200File.getAbsolutePath();
    if (!unpack200File.canExecute()) {
        throw new RuntimeException("please check" +
                cmd + " exists and is executable");
    }
    return cmd;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:14,代碼來源:Utils.java

示例15: findCommand0

import java.io.File; //導入方法依賴的package包/類
private static String findCommand0(String name) {
    for (String path : paths) {
        File file = new File(path, name);
        if (file.canExecute()) {
            return file.getPath();
        }
    }
    return null;
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:10,代碼來源:UnixCommands.java


注:本文中的java.io.File.canExecute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。