Java File Attribute setExecute(File f, boolean b)

Here you can find the source of setExecute(File f, boolean b)

Description

set Execute

License

Open Source License

Declaration

public static boolean setExecute(File f, boolean b) 

Method Source Code

//package com.java2s;
/**/*from   w ww  .jav a 2  s .c  o m*/
 * @(#)FileUtil.java
 *
 * Copyright (2003) Bro3
 * 
 * This program 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 2, or any later version.
 * 
 * This program 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 
 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 * Place, Boston, MA 02111.
 * 
 * Contact: bro3@users.sourceforge.net
 **/

import java.io.*;

public class Main {
    public static boolean setExecute(File f, boolean b) {

        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;
        }

        return true;
    }
}

Related

  1. persistExecutionTimesCsv(String filePath, LinkedList> executionTimes)
  2. setExecutable(File f, final String pattern)
  3. setExecutable(File file)
  4. setExecutable(File file, boolean executable)
  5. setExecutable(String filesList)
  6. setExecute(String path)
  7. setExecutePermissions(final File scriptfile)
  8. setRecursiveExecutable(File path)
  9. setSharedPermissions(File file, boolean setExecutable)