当前位置: 首页>>代码示例>>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;未经允许,请勿转载。