问题
How can I convert a chmod value like 755 so it fits in channelSftp setPermission(int permission, String path)?
I can't figure it out. :(
EDIT: Here it says I'm suppose to use a bitmask. But I'm not sure how that would be done either. http://epaul.github.com/jsch-documentation/javadoc/com/jcraft/jsch/SftpATTRS.html#setPERMISSIONS(int)
回答1:
Permission perm = new Permission();
//set the permissions you want.
setPermission(perm.getDecimalCode(), path);
You can get the Permission class from here:
http://svn.cyberduck.ch/tags/release-2-3/source/ch/cyberduck/core/Permission.java
回答2:
I know that it's digging up an old grave but I have better solution - SftpChannel.chmod expects decimal integer while unix format (644, 777 etc.) is octal. All you have to do is simple conversion:
SftpChannel.chmod(Integer.parseInt(""+, 8), path);
回答3:
channelSftp.chown(0755, f.getName());
来源:https://stackoverflow.com/questions/12582444/how-to-set-chmod-permission-in-java-jsch-channelsftp-setpermissionint-permissio