Tag: 文件权限

如何检查PDF是否受密码保护

我正在尝试使用iText的PdfReader来检查给定的PDF文件是否受密码保护,但是我得到了这个例外: 线程“主线程”中的exceptionjava.lang.NoClassDefFoundError:org / bouncycastle / asn1 / ASN1OctetString 但是,当针对非密码保护的文件测试相同的代码时,它运行正常。 这是完整的代码: try { PdfReader pdf = new PdfReader(“C:\\abc.pdf”); } catch (IOException e) { e.printStackTrace(); }

如何在Java中以编程方式获取文件权限模式

我知道可以使用以下方法更改文件的权限模式: Runtime.getRuntime().exec( “chmod 777 myfile” ); 。 此示例将权限位设置为777 。 是否可以使用Java以编程方式将权限位设置为777 ? 这可以对每个文件进行吗?

log4j RollingFileAppender创建的日志文件的权限

如何确定RollingFileAppender创建的文件的权限? 我最近更改了一个守护进程,我必须以非root用户身份运行,现在正在使用0600权限创建文件(只有所有者可读),但我希望所有或至少成员都能读取它们管理员组( 0644或0640 )。 我的tomcat应用程序创建的文件总是0644 (所有人都可读)。 我不知道我是否无意中改变了其他内容,或者是否与该用户的权限有关。 我将父目录0777作为测试,它似乎没有帮助(它是0755 )。 显然不是什么大不了,因为我可以sudo看他们,但相当恼人,如果我必须让客户为我复制它将是一个问题。 环境是Ubuntu 10.04LTS,使用jsvc/commons-daemon来运行守护进程。 如果重要的是我的log4j配置的基础知识: ….

Java应用程序是否有获得root权限的方法?

当运行Files.walk(Paths.get(“/var/”)).count()作为非特权用户时,执行可能会抛出exception,因为/var/中的文件夹需要遍历root权限。 我不是在寻找一种以root身份执行bash命令的方法(例如sudo find /var ),使用Process等。 我只是想确保Files.walk(Paths.get(“/var/”)).count()不会抛出AccessDeniedException : Exception in thread “restartedMain” java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0 at sun.reflect.NativeMethodAccessorImpl.invoke at sun.reflect.DelegatingMethodAccessorImpl.invoke at java.lang.reflect.Method.invoke at org.springframework.boot.devtools.restart.RestartLauncher.run Caused by: java.io.UncheckedIOException: java.nio.file.AccessDeniedException: /var/cache/httpd at java.nio.file.FileTreeIterator.fetchNextIfNeeded at java.nio.file.FileTreeIterator.hasNext at java.util.Iterator.forEachRemaining at java.util.Spliterators$IteratorSpliterator.forEachRemaining at java.util.stream.AbstractPipeline.copyInto at java.util.stream.AbstractPipeline.wrapAndCopyInto at java.util.stream.ReduceOps$ReduceOp.evaluateSequential at java.util.stream.AbstractPipeline.evaluate at java.util.stream.LongPipeline.reduce at java.util.stream.LongPipeline.sum at java.util.stream.ReferencePipeline.count at com.example.DemoApplication.main … 5 more Caused […]

需要访问系统权限

我试图从data/data访问我的应用程序的文件夹,但它需要将权限更改为0777 。 所以,我使用了一些可以在运行时更改的代码,但权限没有改变。 它给我错误open failed: EACCES (Permission denied) 。 我也把这个权限放在Marshmallow下面的清单文件中我需要像root explorer那样给我们更改文件夹rwxrwxrw 这是我的代码 String[] command = new String[]{“/system/bin/ls”, “0777”, “/data/data/com.ayub.android.baba” }; process = Runtime.getRuntime().exec(command); BufferedReader reader = new BufferedReader( new InputStreamReader(process.getInputStream())); int read; String output = “”; String line; while ((line = reader.readLine()) != null) { output.concat(line + “\n”); Log.w(“myApp”, “[[output]]:” + line); process.waitFor(); } reader.close(); […]

java在创建文件对象时将文件权限设置为777

可能重复: 如何在java中设置umask? 在java中创建文件对象时,如何将文件权限设置为777(或任何其他任意权限)?

如何在java中设置umask?

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