Tabnine Logo
File.setReadable
Code IndexAdd Tabnine to your IDE (free)

How to use
setReadable
method
in
java.io.File

Best Java code snippets using java.io.File.setReadable (Showing top 20 results out of 2,322)

origin: robovm/robovm

/**
 * Equivalent to setReadable(readable, true).
 * @see #setReadable(boolean, boolean)
 * @since 1.6
 */
public boolean setReadable(boolean readable) {
  return setReadable(readable, true);
}
origin: Tencent/tinker

/**
 * create directory
 *
 * @param directoryPath
 */
public static void createDirectory(final String directoryPath) {
  File file = new File(directoryPath);
  if (!file.exists()) {
    file.setReadable(true, false);
    file.setWritable(true, true);
    file.mkdirs();
  }
}
origin: apache/flink

private static void writeYarnProperties(Properties properties, File propertiesFile) {
  try (final OutputStream out = new FileOutputStream(propertiesFile)) {
    properties.store(out, "Generated YARN properties file");
  } catch (IOException e) {
    throw new RuntimeException("Error writing the properties file", e);
  }
  propertiesFile.setReadable(true, false); // readable for all.
}
origin: koral--/android-gif-drawable

@SuppressWarnings("ResultOfMethodCallIgnored") //intended, nothing useful can be done
@SuppressLint("SetWorldReadable") //intended, default permission
private static void setFilePermissions(File outputFile) {
  // Try change permission to rwxr-xr-x
  outputFile.setReadable(true, false);
  outputFile.setExecutable(true, false);
  outputFile.setWritable(true);
}
origin: square/spoon

 @Override protected void plusRWX(File file) {
  file.setReadable(true, false);
  file.setWritable(true, false);
  file.setExecutable(true, false);
 }
}
origin: apache/geode

 public static Path createSecuredTempDirectory(String prefix) throws IOException {
  Path tempDir = Files.createTempDirectory(prefix);
  tempDir.toFile().setExecutable(true, true);
  tempDir.toFile().setWritable(true, true);
  tempDir.toFile().setReadable(true, true);

  return tempDir;
 }
}
origin: Tencent/tinker

/**
 * create file,full filename,signle empty file.
 *
 * @param fullFilename
 * @return boolean
 */
public static boolean createFile(final String fullFilename) {
  boolean result = false;
  File file = new File(fullFilename);
  createDirectory(file.getParent());
  try {
    file.setReadable(true, false);
    file.setWritable(true, true);
    result = file.createNewFile();
  } catch (Exception e) {
    throw new FileUtilException(e);
  }
  return result;
}
origin: neo4j/neo4j

  private void writePem( String type, byte[] encodedContent, File path ) throws IOException
  {
    path.getParentFile().mkdirs();
    try ( PemWriter writer = new PemWriter( new FileWriter( path ) ) )
    {
      writer.writeObject( new PemObject( type, encodedContent ) );
      writer.flush();
    }
    path.setReadable( false, false );
    path.setWritable( false, false );
    path.setReadable( true );
    path.setWritable( true );
  }
}
origin: markzhai/AndroidPerformanceMonitor

private void shareHeapDump(BlockInfoEx blockInfo) {
  File heapDumpFile = blockInfo.logFile;
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
    heapDumpFile.setReadable(true, false);
  }
  Intent intent = new Intent(Intent.ACTION_SEND);
  intent.setType("application/octet-stream");
  intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(heapDumpFile));
  startActivity(Intent.createChooser(intent, getString(R.string.block_canary_share_with)));
}
origin: square/leakcanary

 @Override public void run() {
  //noinspection ResultOfMethodCallIgnored
  heapDumpFile.setReadable(true, false);
  final Uri heapDumpUri = getUriForFile(getBaseContext(),
    "com.squareup.leakcanary.fileprovider." + getApplication().getPackageName(),
    heapDumpFile);
  runOnUiThread(new Runnable() {
   @Override public void run() {
    startShareIntentChooser(heapDumpUri);
   }
  });
 }
});
origin: testcontainers/testcontainers-java

@BeforeClass
public static void setupContent() throws FileNotFoundException {
  contentFolder.mkdir();
  contentFolder.setReadable(true, false);
  contentFolder.setWritable(true, false);
  contentFolder.setExecutable(true, false);
  File indexFile = new File(contentFolder, "index.html");
  indexFile.setReadable(true, false);
  indexFile.setWritable(true, false);
  indexFile.setExecutable(true, false);
  @Cleanup PrintStream printStream = new PrintStream(new FileOutputStream(indexFile));
  printStream.println("<html><body>This worked</body></html>");
}
origin: apache/nifi

@Before
public void prepDestDirectory() throws IOException {
  final File targetDir = new File("target/move-target");
  if (!targetDir.exists()) {
    Files.createDirectories(targetDir.toPath());
    return;
  }
  targetDir.setReadable(true);
  for (final File file : targetDir.listFiles()) {
    Files.delete(file.toPath());
  }
}
origin: testcontainers/testcontainers-java

@SuppressWarnings({"Duplicates", "ResultOfMethodCallIgnored"})
@BeforeClass
public static void setupContent() throws FileNotFoundException {
  contentFolder.mkdir();
  contentFolder.setReadable(true, false);
  contentFolder.setWritable(true, false);
  contentFolder.setExecutable(true, false);
  File indexFile = new File(contentFolder, "index.html");
  indexFile.setReadable(true, false);
  indexFile.setWritable(true, false);
  indexFile.setExecutable(true, false);
  @Cleanup PrintStream printStream = new PrintStream(new FileOutputStream(indexFile));
  printStream.println("<html><body>This worked</body></html>");
}
origin: hamcrest/JavaHamcrest

public void testAReadableFile() { // Not all OSes will allow setting readability so have to be forgiving here.
  file.setReadable(true);
  assertMatches("matches readable file", FileMatchers.aReadableFile(), file);
  if (file.setReadable(false)) {
    assertDoesNotMatch("doesn't match unreadable file", FileMatchers.aReadableFile(), file);
  }
}
origin: apache/zookeeper

@Test
public void testUnreadableFileInput() throws Exception {
  //skip this test on Windows, coverage on Linux
  assumeTrue(!org.apache.zookeeper.Shell.WINDOWS);
  File file = File.createTempFile("test", ".junit", testData);
  file.setReadable(false, false);
  file.deleteOnExit();
  String absolutePath = file.getAbsolutePath();
  String error = ZKUtil.validateFileInput(absolutePath);
  assertNotNull(error);
  String expectedMessage = "Read permission is denied on the file '" + absolutePath + "'";
  assertEquals(expectedMessage, error);
}
origin: neo4j/neo4j

@Test
void lockFileAndFailToDeleteDirectory()
{
  File nonDeletableDirectory = directory.directory( "c" );
  CONTEXT.setValue( LOCKED_TEST_FILE_KEY, nonDeletableDirectory );
  assertTrue( nonDeletableDirectory.setReadable( false, false ) );
}
origin: neo4j/neo4j

@Test
public void shouldLogIfConfigFileCouldNotBeRead() throws IOException
{
  Log log = mock( Log.class );
  File confFile = testDirectory.file( "test.conf" );
  assertTrue( confFile.createNewFile() );
  assumeTrue( confFile.setReadable( false ) );
  Config config = Config.fromFile( confFile ).withNoThrowOnFileLoadFailure().build();
  config.setLogger( log );
  verify( log ).error( "Unable to load config file [%s]: %s", confFile, confFile + " (Permission denied)" );
}
origin: neo4j/neo4j

@Test( expected = ConfigLoadIOException.class )
public void mustThrowIfConfigFileCoutNotBeRead() throws IOException
{
  File confFile = testDirectory.file( "test.conf" );
  assertTrue( confFile.createNewFile() );
  assumeTrue( confFile.setReadable( false ) );
  Config.fromFile( confFile ).build();
}
origin: spotbugs/spotbugs

@Test
public void ignoreUnreadableFile() throws Exception {
  File file = createZipFile();
  file.deleteOnExit();
  file.setReadable(false);
  assumeFalse("File cannot be marked as unreadable, skipping test.", file.canRead());
  FilesystemCodeBaseLocator locator = buildLocator(file);
  assertHasNoCodeBase(ClassFactory.createFilesystemCodeBase(locator));
}
origin: neo4j/neo4j

@Test
@EnabledOnOs( OS.LINUX )
void exceptionOnDirectoryDeletionIncludeTestDisplayName() throws IOException
{
  CONTEXT.clear();
  FailedTestExecutionListener failedTestListener = new FailedTestExecutionListener();
  execute( "lockFileAndFailToDeleteDirectory", failedTestListener );
  File lockedFile = CONTEXT.getValue( LOCKED_TEST_FILE_KEY );
  assertNotNull( lockedFile );
  assertTrue( lockedFile.setReadable( true, true ) );
  FileUtils.deleteRecursively( lockedFile );
  failedTestListener.assertTestObserver();
}
java.ioFilesetReadable

Javadoc

Equivalent to setReadable(readable, true).

Popular methods of File

  • <init>
    Creates a new File instance by converting the givenfile: URI into an abstract pathname. The exact fo
  • exists
    Tests whether the file or directory denoted by this abstract pathname exists.
  • getAbsolutePath
    Returns the absolute pathname string of this abstract pathname. If this abstract pathname is already
  • getName
    Returns the name of the file or directory denoted by this abstract pathname. This is just the last n
  • isDirectory
  • mkdirs
  • delete
    Deletes the file or directory denoted by this abstract pathname. If this pathname denotes a director
  • listFiles
    Returns an array of abstract pathnames denoting the files and directories in the directory denoted b
  • getParentFile
    Returns the abstract pathname of this abstract pathname's parent, or null if this pathname does not
  • getPath
    Converts this abstract pathname into a pathname string. The resulting string uses the #separator to
  • isFile
  • length
    Returns the length of the file denoted by this abstract pathname. The return value is unspecified if
  • isFile,
  • length,
  • toURI,
  • createTempFile,
  • createNewFile,
  • toPath,
  • mkdir,
  • lastModified,
  • toString,
  • getCanonicalPath

Popular in Java

  • Start an intent from android
  • scheduleAtFixedRate (Timer)
  • runOnUiThread (Activity)
  • getSharedPreferences (Context)
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • Pattern (java.util.regex)
    Patterns are compiled regular expressions. In many cases, convenience methods such as String#matches
  • HttpServletRequest (javax.servlet.http)
    Extends the javax.servlet.ServletRequest interface to provide request information for HTTP servlets.
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • LogFactory (org.apache.commons.logging)
    Factory for creating Log instances, with discovery and configuration features similar to that employ
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.> This module, both source code and documentation, is in t
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now