Generate files with all permissions

1

I'm generating * .csv files from this:

BufferedWriter strW = new BufferedWriter(new FileWriter(caminhoCSV.toString()))

But the generated files are only read-only, how could I change this so that the generated file has read and change permission?

    
asked by anonymous 24.08.2017 / 20:19

2 answers

2

You can even use the File class after the file is generated

String caminho = "caminho/do/meu/arquivo";

final File file = new File(caminho);
file.setReadable(true, false);
file.setExecutable(true, false);
file.setWritable(true, false);
    
24.08.2017 / 20:31
1

You can call the unix command, if you are using an O.S based on it, through Runtime.exec, note:

Runtime.getRuntime().exec("chmod 666 caminho_arquivo");

Be careful when concatenating a string, it must have a space between 666 and the file path.

    
24.08.2017 / 20:26