在Java中解析XML的访问权 [英] access right to parse an XML in java
问题描述
您好,我必须执行以下命令:
hello i have to execute this command:
docRules = DocumentBuilderFactory.newInstance()
.newDocumentBuilder().parse( new File(IeplcDeployRules.clx));
当我尝试创建解析器时,出现以下错误:
When i try to create a parser i get the following error:
java.io.FileNotFoundException: /.../IeplcDeployRules.clx (Permission denied)
如果我尝试手动读取该文件,则该文件有效,但由于以下权限,我无法写入该文件.
if i try manually to read the file it works but i cannot write in it because following are the permission.
-rwxr-xr-x 1 ieplcop ieplcdev 3424 Aug 11 17:16 IeplcDeployRules.clx
由于文件只需要从我的Java应用程序读取,因此我不想更改权限.因此,我想有一种方法可以指定应以只读模式打开文件.
I do not want to change the permission since the file NEED only to be read from my Java application. I suppose there shold be therefore a way to specify that the file should be opened in read only mode.
我看了File()parse()和.newDocumentBuilder()的可能参数,但没有一个让我指定操作是只读的!
I look the possible paramenter of File() parse() and .newDocumentBuilder() but none of them let me specify that the operation is read only!!
关于如何进行的任何想法?
Any idea about how to procede?
干杯, Ste
推荐答案
我不知道DocumentBuilder
在内部的作用,我必须阅读其源代码.但是您可以使用其他InputSource
代替File
,以便完全控制.例如, FileReader .
I do not know what the DocumentBuilder
does internally, I would have to read its source. But you can use a different InputSource
instead of a File
, so that you have full control. For example a FileReader.
documentBuilder.parse(new InputSource(new FileReader(...));
这篇关于在Java中解析XML的访问权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!