Here you can find the source of checkFilePermissions(final String filepath, final boolean canRead, final boolean canWrite)
public static void checkFilePermissions(final String filepath, final boolean canRead, final boolean canWrite)
//package com.java2s; /* JMultiPatcher - yet another rompatcher utility Copyright ? 2014 Josef Andersson <josef.andersson@fripost.org> /*from w w w. j ava 2 s. c om*/ This file is part of JMultiPatcher. JMultiPatcher is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version. JMultiPatcher is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with JMultiPatcher. If not, see <http://www.gnu.org/licenses/>. */ import java.io.File; import java.nio.file.Path; import java.nio.file.Paths; public class Main { public static void checkFilePermissions(final String filepath, final boolean canRead, final boolean canWrite) { final Path path = Paths.get(filepath); final File file = path.toFile(); if (canRead && !file.canRead()) { throw new IllegalArgumentException("Can't read file" + filepath); } if (canWrite && !file.canWrite()) { throw new IllegalArgumentException("Can't write to file" + filepath); } } }