当前位置: 首页>>代码示例>>Java>>正文


Java File.setReadable方法代码示例

本文整理汇总了Java中java.io.File.setReadable方法的典型用法代码示例。如果您正苦于以下问题:Java File.setReadable方法的具体用法?Java File.setReadable怎么用?Java File.setReadable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.io.File的用法示例。


在下文中一共展示了File.setReadable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onPause

import java.io.File; //导入方法依赖的package包/类
@Override
public void onPause() {
    // From https://forum.xda-developers.com/xposed/how-to-save-load-module-settings-t3640881
    super.onPause();

    // Set preferences permissions to be world readable
    // Workaround for Android N and above since MODE_WORLD_READABLE will cause security exception and FC.
    final File dataDir = new File(getActivity().getApplicationInfo().dataDir);
    final File prefsDir = new File(dataDir, "shared_prefs");
    final File prefsFile = new File(prefsDir, getPreferenceManager().getSharedPreferencesName() + ".xml");

    if (prefsFile.exists()) {
        dataDir.setReadable(true, false);
        dataDir.setExecutable(true, false);

        prefsDir.setReadable(true, false);
        prefsDir.setExecutable(true, false);

        prefsFile.setReadable(true, false);
        prefsFile.setExecutable(true, false);
    }
}
 
开发者ID:xddxdd,项目名称:lantian-nolitter,代码行数:23,代码来源:SettingsFragment.java

示例2: changeFilePermisson4Win

import java.io.File; //导入方法依赖的package包/类
/**
 * Change the permission of the file to --Readable, Writable, Executable--
 * 
 * @param fileName
 */
public static void changeFilePermisson4Win(String fileName) {

    File file = new File(fileName);
    if (!file.exists()) {
        return;
    }

    if (!file.canRead()) {
        file.setReadable(true);
    }

    if (!file.canWrite()) {
        file.setWritable(true);
    }

    if (!file.canExecute()) {
        file.setExecutable(true);
    }
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:25,代码来源:UpgradeUtil.java

示例3: writePrivateKey

import java.io.File; //导入方法依赖的package包/类
/**
 * writes private key
 *
 * @param key String
 */
protected String writePrivateKey(String key) {
  String uuid = UUID.randomUUID().toString();
  String fileName = config.getDataDir() + "/" + uuid;
  try (BufferedWriter bw = Files.newBufferedWriter(Paths.get(fileName))) {
    bw.write(key);
    bw.close();
    File f = new File(fileName);
    f.setExecutable(false, false);
    f.setReadable(false, false);
    f.setWritable(false, false);
    f.setReadable(true, true);
    f.setWritable(true, true);
    logger.debug("file: " + fileName);
  } catch (IOException e) {
    logger.error("could not write file: " + fileName + " msg:"
        + e.getMessage());
  }
  return fileName;
}
 
开发者ID:oneops,项目名称:oneops,代码行数:25,代码来源:AbstractOrderExecutor.java

示例4: retrieveRelevantFiles

import java.io.File; //导入方法依赖的package包/类
private final List<File> retrieveRelevantFiles(String filePath) {
    final File path = new File(filePath);

    if (!path.exists()) {
        errorString = "Provided search path does not exist: " + filePath;
        return null;
    }

    if (!path.isDirectory()) {
        errorString = "Provided path exists but is not a directory: " + filePath;
        return null;
    }

    if (!path.canRead()) {
        if (!path.setReadable(true)) {
            errorString = "Provided path exists but is not readable: " + filePath;
            return null;
        }
    }

    return retrieveRelevantFiles(path, 0);
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:23,代码来源:SnapshotScan.java

示例5: initBundled

import java.io.File; //导入方法依赖的package包/类
private void initBundled() throws IOException {
    File tmpDir = new File(System.getProperty("java.io.tmpdir"), "solc");
    tmpDir.setReadable(true);
    tmpDir.setWritable(true);
    tmpDir.setExecutable(true);
    tmpDir.mkdirs();

    String solcPath = "/native/" + getOS() + "/solc/";
    InputStream is = getClass().getResourceAsStream(solcPath + "file.list");
    Scanner scanner = new Scanner(is);
    while (scanner.hasNext()) {
        String s = scanner.next();
        File targetFile = new File(tmpDir, s);
        InputStream fis = getClass().getResourceAsStream(solcPath + s);
        Files.copy(fis, targetFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
        if (solc == null) {
            // first file in the list denotes executable
            solc = targetFile;
            solc.setExecutable(true);
        }
        targetFile.deleteOnExit();
    }
    tmpDir.deleteOnExit();
}
 
开发者ID:web3j,项目名称:web3j-maven-plugin,代码行数:25,代码来源:SolC.java

示例6: throws_exception_when_provided_java_file_is_not_accessible

import java.io.File; //导入方法依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void throws_exception_when_provided_java_file_is_not_accessible() throws IOException {
    compiler.init(
            folder.getRoot().getAbsolutePath(),
            new DefaultDependencyResolver(),
            new DefaultInternalCompiler()
    );

    final File javaFile = folder.newFile();
    javaFile.setReadable(false);
    compiler.compile(javaFile.getAbsolutePath(), null);
}
 
开发者ID:dshell-io,项目名称:dshell,代码行数:13,代码来源:DefaultJavaFileCompilerTest.java

示例7: retrieveRelevantFiles

import java.io.File; //导入方法依赖的package包/类
private final List<File> retrieveRelevantFiles(String filePath, String nonce) {
    final File path = new File(filePath);

    if (!path.exists()) {
        errorString = "Provided search path does not exist: " + filePath;
        return null;
    }

    if (!path.isDirectory()) {
        errorString = "Provided path exists but is not a directory: " + filePath;
        return null;
    }

    if (!path.canRead()) {
        if (!path.setReadable(true)) {
            errorString = "Provided path exists but is not readable: " + filePath;
            return null;
        }
    }

    if (!path.canWrite()) {
        if (!path.setWritable(true)) {
            errorString = "Provided path exists but is not writable: " + filePath;
            return null;
        }
    }

    return retrieveRelevantFiles(path, nonce);
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:30,代码来源:SnapshotDelete.java

示例8: createFile

import java.io.File; //导入方法依赖的package包/类
private static File createFile(String path) {
    if (DBG) Log.d(TAG, "createFile: " + path);
    File f = new File(path);
    if (f.exists())
        return f;
    try {
        f.createNewFile();
        f.setReadable(true, false);
    } catch (IOException e) {
        Log.e(TAG, "could not create file:" + path, e);
    }
    return f;
}
 
开发者ID:archos-sa,项目名称:aos-MediaLib,代码行数:14,代码来源:ImageScaler.java

示例9: testFileSystemSecretsLocker_notReadable

import java.io.File; //导入方法依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void testFileSystemSecretsLocker_notReadable() {
    File tmpdir = new File(System.getProperty("java.io.tmpdir") + "/foo");

    tmpdir.deleteOnExit();
    tmpdir.mkdir();
    tmpdir.setReadable(false);

    secretsLocker = new FileSystemSecretsLocker(tmpdir.getAbsolutePath());
}
 
开发者ID:eonian-technologies,项目名称:secrets-locker,代码行数:11,代码来源:FileSystemSecretsLockerTest_constructor.java

示例10: changeFilePermission755

import java.io.File; //导入方法依赖的package包/类
public static boolean changeFilePermission755(final File file) {
    try {
        if (file == null || !file.exists()) {
            return false;
        }

        file.setReadable(true, false);
        file.setExecutable(true, false);
        file.setWritable(true, true);
    } catch (Exception e) {
        e.printStackTrace();
    }

    return false;
}
 
开发者ID:miLLlulei,项目名称:Accessibility,代码行数:16,代码来源:FileUtils.java

示例11: testReadError

import java.io.File; //导入方法依赖的package包/类
@Test
public void testReadError() {
    final Optional<Resource> res = CachedResource.find(readonly2, rdf.createIRI("trellis:repository/ldpnr"));
    assertTrue(res.isPresent());

    final File quads = new File(readonly2, RESOURCE_QUADS);
    assumeTrue(quads.setReadable(false));
    assertEquals(0L, res.get().stream().count());
    quads.setReadable(true);
}
 
开发者ID:trellis-ldp-archive,项目名称:trellis-rosid-file,代码行数:11,代码来源:CachedResourceTest.java

示例12: fixFilePermissions

import java.io.File; //导入方法依赖的package包/类
public static void fixFilePermissions() {
	File folder = new File(Util.getUserDataDirectory(Process.myUid()) + File.separator + "shared_prefs");
	folder.setReadable(true, false);
	File[] files = folder.listFiles();
	if (files != null)
		for (File file : files)
			if (file.getName().startsWith("biz.bokhorst.xprivacy.provider.") && file.getName().endsWith(".xml")
					&& !file.getName().contains(".usage."))
				file.setReadable(true, false);
}
 
开发者ID:ukanth,项目名称:XPrivacy,代码行数:11,代码来源:PrivacyProvider.java

示例13: configFileIsNotReadable

import java.io.File; //导入方法依赖的package包/类
@Test
public void configFileIsNotReadable() throws IOException {
  File file = temp.newFile("application.yml");
  file.setReadable(false);
  when(env.getProperty(anyString())).thenReturn(file.getAbsolutePath());

  try {
    listener.onApplicationEvent(event);
    fail();
  } catch (ConfigFileValidationException e) {
    String error = e.getErrors().get(0).getDefaultMessage();
    assertThat(error, containsString("Config file " + file.getAbsolutePath() + " cannot be read."));
  }
}
 
开发者ID:HotelsDotCom,项目名称:circus-train,代码行数:15,代码来源:ConfigFileValidationApplicationListenerTest.java

示例14: throws_exception_when_provided_workspace_is_not_readable

import java.io.File; //导入方法依赖的package包/类
@Test(expected = IllegalArgumentException.class)
public void throws_exception_when_provided_workspace_is_not_readable() throws IOException {
    final File root = folder.newFolder();
    root.setReadable(false);

    compiler.init(root.getAbsolutePath(), new DefaultDependencyResolver(), new DefaultInternalCompiler());
}
 
开发者ID:dshell-io,项目名称:dshell,代码行数:8,代码来源:DefaultJavaFileCompilerTest.java

示例15: shareHeapDump

import java.io.File; //导入方法依赖的package包/类
private void shareHeapDump() {
    File heapDumpFile = getVisibleLeak().heapDump.heapDumpFile;
    heapDumpFile.setReadable(true, false);
    Intent intent = new Intent("android.intent.action.SEND");
    intent.setType("application/octet-stream");
    intent.putExtra("android.intent.extra.STREAM", Uri.fromFile(heapDumpFile));
    startActivity(Intent.createChooser(intent, getString(R.string.__leak_canary_share_with)));
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:9,代码来源:DisplayLeakActivity.java


注:本文中的java.io.File.setReadable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。