Why file writing permission is not set correctly in Java 7?

Could somebody explain me, why writing permission isn't set for others by the following code snippet on Ubuntu 13.04 and java 1.7 (OpenJDK 64bit). All other permissions are set correctly, except the writing for others, which I think is suspicious.

public void testCreateFileWithPermissions() throws IOException {
    Path target = Paths.get(TEST_FILE);
    cadf.createFileWithPermissions(target, "rwxrwxrwx");
    Set<PosixFilePermission> perms = Files.getPosixFilePermissions(target);
    for (PosixFilePermission perm : perms) {
      System.out.println(perm.toString());
    }
  }

public void createFileWithPermissions(Path target, String permissions)
      throws IOException {
    Set<PosixFilePermission> perms = PosixFilePermissions
        .fromString(permissions);
    FileAttribute<Set<PosixFilePermission>> attr = PosixFilePermissions
        .asFileAttribute(perms);
    Files.createFile(target, attr);
  }

I got the following output:

OWNER_WRITE
OTHERS_EXECUTE
GROUP_READ
OWNER_READ
GROUP_EXECUTE
GROUP_WRITE
OWNER_EXECUTE
OTHERS_READ

Answers


According to CPU 100 comment, I made a quick search about umask and it turned out I was on the default value, which is 0002. Thus, I couldn't create any files with writting permissions for other users. Here is a good explanation of umask.


Since changing the umask was no option for me I use Files.setPosixFilePermissions(Path, Set<PosixFilePermission>) after creating the file.


Need Your Help

How do I get the page content from PAMIE?

python pamie

I'm using PAMIE to control IE to automatically browse to a list of URLs. I want to find which URLs return IE's malware warning and which ones don't. I'm new to PAMIE, and PAMIE's documentation is non-

Selenium Marionette driver UnreachableBrowserException upon second launch

java selenium selenium-webdriver firefox-marionette

I'm currently playing around with the Selenium Marionette WebDriver. In my application, I want to open multiple Marionette drivers sequentially. Basically something like this: