创建{@link RandomAccessFile}

@param path 文件Path
@param mode 模式，见{@link FileMode}
@return {@link RandomAccessFile}
@since 4.5.2
356825
public static RandomAccessFile createRandomAccessFile(Path path, FileMode mode) {
		return createRandomAccessFile(path.toFile(), mode);
	}
981234
public static String permissions(Path path) {
        try {
            return permissions(getUnixMode(path));
        } catch (IOException e) {
            throw Exceptions.propagate(e);
        }
    }
526923
@Override
    public void checkAccess(final Path path, final AccessMode... modes) throws IOException {
        // We support READ, WRITE, and EXECUTE on everything, so long as a file exists
        final Archive<?> archive = this.getArchive(path);
        final String desired = path.toString();
        if (!archive.contains(desired)) {
            throw new NoSuchFileException(desired);
        }
    }
612964
@NonNull
    private static String randomMediaPath(File bucket, String extension) {
        if (bucket.exists() && bucket.isFile()) bucket.delete();
        if (!bucket.exists()) bucket.mkdirs();
        String outFilePath = AlbumUtils.getNowDateTime("yyyyMMdd_HHmmssSSS") + "_" + getMD5ForString(UUID.randomUUID().toString()) + extension;
        File file = new File(bucket, outFilePath);
        return file.getAbsolutePath();
    }
257520
public Sftp put(String srcFilePath, String destPath, Mode mode) {
		try {
			channel.put(srcFilePath, destPath, mode.ordinal());
		} catch (SftpException e) {
			throw new JschRuntimeException(e);
		}
		return this;
	}
374024
public static File checkFolderPath(final String path, final boolean create) {
		final File file = new File(path);
		if (!file.exists()) {
			if (create) {
				file.mkdir();
			}
			return null;
		}
		return file;
	}
1098863
@PublicEvolving
	public void write_as_text(String path, WriteMode mode) {
		stream.writeAsText(path, mode);
	}
1101722
private FSDirectory openLuceneDirectory(final File path) {
      try {
         return FSDirectory.open(path.toPath());
      }
      catch (IOException e) {
         throw log.exceptionInCacheLoader(e);
      }
   }
14732
public static RubyIO open(String path, String mode) {
    RubyIO io = null;
    try {
      io = new RubyIO(new File(path), Mode.fromString(mode));
    } catch (IOException e) {
      logger.log(Level.SEVERE, null, e);
      throw new RuntimeException(e);
    }
    return io;
  }
483945
public static RandomAccessFastaIndex index(Path file, int indexStep, boolean save, LongProcessReporter reporter) {
        Path indexFile = file.resolveSibling(file.getFileName() + INDEX_SUFFIX);

        if (Files.exists(indexFile))
            try (FileInputStream fis = new FileInputStream(indexFile.toFile())) {
                RandomAccessFastaIndex index = RandomAccessFastaIndex.read(new BufferedInputStream(fis));
                if (index.getIndexStep() != indexStep)
                    throw new IllegalArgumentException("Mismatched index step in " + indexFile + ". Remove the file to recreate the index.");
                return index;
            } catch (IOException e) {
                throw new RuntimeException(e);
            }

        try (LongProcess lp = reporter.start("Indexing " + file.getFileName());
             FileChannel fc = FileChannel.open(file, StandardOpenOption.READ)) {
            // Requesting file size to correctly report status
            long size = Files.size(file);

            // Allocating buffer
            ByteBuffer buffer = ByteBuffer.allocate(65536);
            // Extracting backing byte array
            byte[] bufferArray = buffer.array();
            // Creating builder
            StreamIndexBuilder builder = new StreamIndexBuilder(indexStep);

            // Indexing file
            int read;
            long done = 0;
            while ((read = fc.read((ByteBuffer) buffer.clear())) > 0) {
                builder.processBuffer(bufferArray, 0, read);
                lp.reportStatus(1.0 * (done += read) / size);
            }

            // Build index
            RandomAccessFastaIndex index = builder.build();

            if (save)
                try (FileOutputStream fos = new FileOutputStream(indexFile.toFile())) {
                    index.write(new BufferedOutputStream(fos));
                }

            return index;
        } catch (IOException ioe) {
            throw new RuntimeException(ioe);
        }
    }
102189
@SuppressWarnings("resource")
    public static FileChannel openChannel(File file, boolean mutable) throws IOException {
        if (mutable) {
            return new RandomAccessFile(file, "rw").getChannel();
        }
        return new FileInputStream(file).getChannel();
    }
1334204
public static void createFileWithDefault(String filePath, long length) throws IOException {
    Path path = Paths.get(filePath);
    try {
      Files.deleteIfExists(path);
      try (
          RandomAccessFile randomAccessFile = new RandomAccessFile(filePath, "rw");
      ) {
        randomAccessFile.setLength(length);
      }
    } catch (IOException e) {
      throw new IOException("create spares file fail,path:" + filePath + " length:" + length, e);
    }
  }
51581
public static function chmod($path, $mode = null)
  {
    if ($mode) {
      return chmod($path, $mode);
    }

    return substr(sprintf('%o', fileperms($path)), -4);
  }
604693
def set_mode(path, mode):
    '''
    
    '''
    path = os.path.expanduser(path)

    mode = six.text_type(mode).lstrip('0Oo')
    if not mode:
        mode = '0'
    if not os.path.exists(path):
        raise CommandExecutionError('{0}: File not found'.format(path))
    try:
        os.chmod(path, int(mode, 8))
    except Exception:
        return 'Invalid Mode ' + mode
    return get_mode(path)
345846
public static RandomAccessFastaIndex index(Path file, boolean save, LongProcessReporter reporter) {
        try {
            // This calculates indexStep so the final index size will not exceed 1Mb
            // (approximately)
            long size = Files.size(file);
            long step = size / 131072;
            if (step < 128)
                step = 128;
            int iStep = 1 << (64 - numberOfLeadingZeros(step) + (bitCount(step) > 1 ? 1 : 0));

            // Index file
            return index(file, iStep, save, reporter);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
957650
@NonNull
    public static String randomMP4Path(Context context) {
        if(!Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
            return randomMP4Path(context.getCacheDir());
        }
        return randomMP4Path();
    }
621369
public static ByteBuffer create(Path path, int maxSize) throws IOException
    {
        try (FileChannel fc = FileChannel.open(path, READ, WRITE, CREATE))
        {
            return fc.map(FileChannel.MapMode.READ_WRITE, 0, maxSize);
        }
    }