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?
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.