Here you can find the source of Chmod(boolean recursive, String permission, String directoryFile)
private static void Chmod(boolean recursive, String permission, String directoryFile) throws IOException
//package com.java2s; /*/* www . ja v a 2s . c o m*/ * SSHTools - VO Management Tool * * Copyright (C) 2013 Siew Hoon Leong * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public License * as published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * You may also distribute it and/or modify it under the terms of the * Apache style J2SSH Software License. A copy of which should have * been provided with the distribution. * * 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 * License document supplied with your distribution for more details. * */ import java.io.IOException; public class Main { /** * Change permission of files and directories */ private static void Chmod(boolean recursive, String permission, String directoryFile) throws IOException { String osName = System.getProperty("os.name"); String command = "chmod"; if (recursive) { command += " -R"; } if (osName.startsWith("Mac OS")) { Runtime.getRuntime().exec( command + " " + permission + " " + directoryFile); } else if (osName.startsWith("Windows")) { //Nothing can be done currently } else { Runtime.getRuntime().exec( command + " " + permission + " " + directoryFile); } } }