如何在java中设置umask? [英] How can I set the umask from within java?

查看:752
本文介绍了如何在java中设置umask?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Java的新手。 api中umask暴露在哪里?

I'm new to Java. Where is umask exposed in the api?

推荐答案

你不能直接使用umask,因为Java是一个抽象而且umask是特定于POSIX的实现。但是您有以下API:

You can't fiddle with the umask directly, since Java is an abstraction and the umask is POSIX-implementation specific. But you have the following API:

File f;
f.setExecutable(true);
f.setReadable(false);
f.setWritable(true);

还有更多的API,检查文档

如果你必须可以直接访问umask,可以通过JNI和 chmod()系统调用,也可以使用生成新进程exec(chmod)

If you must have direct access to the umask, either do it via JNI and the chmod() syscall, or spawn a new process with exec("chmod").

这篇关于如何在java中设置umask?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆