Hip Hip Array
Hip Hip Array

Reputation: 4773

Creating new folders that have read-write access

I am currently creating a directory based on file names and then moving the files into the new directories. At the moment i am creating the new directories fine using the following code:

String filename = filesInFolder.get(i).toString();
File fullPathFile = new File(filename.replaceAll("(\\w+)_(\\d+).*", "$1/$2/$0"));
fullPathFile.getParentFile().mkdirs();

Then i am trying to use InputStream and OutputStream to move the files to the new directories, the code is ok it seems but when i create the new directories, all the folders are set to read-only so i cannot move the files into the knew directories

So is there a way to set the folders to read-write when they are created?

Upvotes: 3

Views: 4386

Answers (1)

Joseph Elcid
Joseph Elcid

Reputation: 877

I believe fullPathFile.getParentFile().setWritable(true) before calling mkdirs() should do. The method setWritable (bool) is a convenience method to set the owner's write permission for this abstract pathname.
Since is a File, you can apply it.

Upvotes: 3

Related Questions