Skip to content

Instantly share code, notes, and snippets.

@RurioLuca
Created October 9, 2016 16:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RurioLuca/6e2b742bd456d9da95a6167b6badbbb2 to your computer and use it in GitHub Desktop.
Save RurioLuca/6e2b742bd456d9da95a6167b6badbbb2 to your computer and use it in GitHub Desktop.
File serverFile = new File(dir.getAbsolutePath()
+ file.getOriginalFilename());
serverFile.setWritable(true, false);
serverFile.setExecutable(true, false);
serverFile.setReadable(true, false);
BufferedOutputStream stream = null;
stream = new BufferedOutputStream(new FileOutputStream(serverFile));
stream.write(bytes);
stream.close();
Set perms = new HashSet();
perms.add(PosixFilePermission.OWNER_READ);
perms.add(PosixFilePermission.OWNER_WRITE);
perms.add(PosixFilePermission.OTHERS_READ);
perms.add(PosixFilePermission.OTHERS_WRITE);
Files.setPosixFilePermissions(serverFile.toPath(), perms);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment