Java IOException: Permission denied on linux while running as owner

I need to create some directories and files and all of them should have permission 0600.
When I Run from NetBeans Debug: After creating directory when i try to store some files there I get IOException with "Permission Denied" message while both directories and files are created with same application at the same time with the same user so I think 0600 (owner read/write) should work.
And When Running Jar file, chmod doesn't work at all! My code is:

if(!Dest.exists()){
   boolean res=dirs.mkdirs();
   if(res){
      Runtime.getRuntime().exec("chmod -R 600 '"+dirs.getAbsolutePath()+"'");                
    }
}
File Destination=new File(Dest, source.getName());
documentManager.copyFile(source, Destination);

and the copyFile is:

public static void copyFile(File sourceFile, File destFile) throws FileNotFoundException,IOException {
    if(!destFile.exists()) {
        destFile.createNewFile();
    }

    FileChannel source = null;
    FileChannel destination = null;
    try {
        source = new FileInputStream(sourceFile).getChannel();
        destination = new FileOutputStream(destFile).getChannel();
        destination.transferFrom(source, 0, source.size());
    }
    finally {
        if(source != null) {
            source.close();
        }
        if(destination != null) {
            Runtime.getRuntime().exec("chmod 600 '"+destFile.getAbsolutePath()+"'");
            destination.close();
        }
    }
}

What's the problem?

Thanks

Answer:1

The directory needs to have the executable bit set for you to write files into it. Try chmod +x on the directory.

mkdir tmp2323
chmod a-x tmp2323
touch tmp2323/test
touch: cannot touch `tmp2323/test': Permission denied
Answer:2

For all:

dirs.setWritable(true, false);

For only owner:

dirs.setWritable(true, true);

or

dirs.setWritable(true);
Answer:3

I am writing a program which reads in files and then processes them. At the moment, I am using a BufferedReader to read in a list of files from a txt file. This txt file was generated in a command ...

Question about ScheduledExecutorService.shceduleAtFixedRate - I schedule taskA to run every 500 millis, which blocks for 1000 millis. Now subsequent executions aren't gonna wait the extra 500 millis, ...

Take any OOPs language with referencing as basic structure like java and c#. For fast execution, they also support primitive types like int and char. I think this is done by storing them on the stack....

Someone asked me if he can run private base function. I told him that of course it is not possible (apart from trick of relection). But what the hell is this: public class MyClass { public ...