Write an executable .sh file with Java for OSX

后端 未结 5 1310
情书的邮戳
情书的邮戳 2021-01-18 00:59

So I am trying to write an .sh file that will be executable, this is how I\'m currently writing it:

Writer output = null;

try {
  output = new BufferedWrite         


        
5条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-18 01:14

    You can call File.setExecutable() to set the owner's executable bit for the file, which might be sufficient for your case. Or you can just chmod it yourself with a system call with Process.

    Alas, full-powered programmatic alteration of file permissions isn't available until Java 7. It'll be part of the New IO feature set, which you can read more about here.

提交回复
热议问题