Java Utililty Methods File Attribute

List of utility methods to do File Attribute

Description

The list of methods to do File Attribute are organized into topic(s).

Method

booleanpatchInfoPList(final File infoPList, final String executable)
patch Info P List
if (!infoPList.exists())
    return false;
String contents = readFile(infoPList);
final Pattern pattern = Pattern.compile(".*<key>CFBundleExecutable</key>[^<]*<string>([^<]*).*",
        Pattern.DOTALL | Pattern.MULTILINE);
final Matcher matcher = pattern.matcher(contents);
if (!matcher.matches())
    return false;
...
voidpersistExecutionTimesCsv(String filePath, LinkedList> executionTimes)
persist Execution Times Csv
PrintWriter out = null;
try {
    out = new PrintWriter(new BufferedWriter(new FileWriter(filePath, false)));
    for (Map.Entry<String, Double> entry : executionTimes) {
        out.println(entry.getKey() + ";" + entry.getValue());
} finally {
    if (out != null) {
...
voidsetExecutable(File f, final String pattern)
set Executable
if (f.isDirectory()) {
    File[] files = f.listFiles(new FilenameFilter() {
        @Override
        public boolean accept(File dir, String name) {
            return Pattern.matches(pattern, name);
    });
    for (File bin : files) {
...
booleansetExecutable(File file)
set Executable
try {
    new FilePermission(file.getAbsolutePath(), "execute");
    return true;
} catch (Exception e) {
    return false;
voidsetExecutable(File file, boolean executable)
set Executable
if (executable && !file.setExecutable(true)) {
    throw new IOException("Cannot set executable permissions for: " + file);
voidsetExecutable(String filesList)
set Executable
Runtime.getRuntime().exec("chmod u+x " + filesList);
booleansetExecute(File f, boolean b)
set Execute
try {
    Process p = null;
    String cmd = null;
    cmd = "chmod " + "u+x" + " " + f.getAbsolutePath();
    p = Runtime.getRuntime().exec(cmd);
} catch (Exception e) {
    e.printStackTrace();
    return false;
...
booleansetExecute(String path)
set Execute
try {
    Process proc = Runtime.getRuntime().exec(new String[] { "chmod", "a+x", path });
    proc.waitFor();
    return true;
} catch (InterruptedException ex) {
} catch (IOException ex) {
return false;
...
voidsetExecutePermissions(final File scriptfile)
Set the executable flag on a file if supported by the OS
if (!scriptfile.setExecutable(true, true)) {
    System.err.println("Unable to set executable bit on temp script file, execution may fail: "
            + scriptfile.getAbsolutePath());
voidsetRecursiveExecutable(File path)
set Recursive Executable
for (File f : path.listFiles()) {
    if (f.isDirectory()) {
        f.setExecutable(true);
        setRecursiveExecutable(f);
    } else if (!f.canExecute() && (f.getName().endsWith(".so") || f.getName().endsWith(".dll"))) {
        f.setExecutable(true);