i'm getting different result files.exists(path)
path.tofile().exists()
local file on windows. can see file in windows explorer although have (randomly) modified permissions , perhaps permissions not make sense.
however doesn't explain why old method returns true , new methods returns false. file definently exists maybe invisible user running java code, i'm not sure correct answer should be. nor can see how see user running code, there 1 real user paul on computer, i'm wondering if whether if run administrator or not effects things.
system.out.println("path exists(1):"+files.exists(path)); system.out.println("path exist(2) :"+path.tofile().exists());
gives
path exists(1):false path exist(2) :true
also
system.out.println("path readable(3) :"+files.isreadable(path)); system.out.println("path readable(4):"+path.tofile().canread());
works in same way giving
path readable(3) :false path readable(4):true
permissions output
file c:\code\jthink\opensrc\jaudiotagger\testdata\test157.dsf permissions owner:pclaptop\paul nt authority\system:read_data/write_data/append_data/read_named_attrs/write_named_attrs/execute/delete_child/read_attributes/write_attributes/delete/read_acl/write_acl/write_owner/synchronize:deny builtin\administrators:read_data/write_data/append_data/read_named_attrs/write_named_attrs/execute/delete_child/read_attributes/write_attributes/delete/read_acl/write_acl/write_owner/synchronize:deny builtin\administrators:read_data/write_data/append_data/read_named_attrs/write_named_attrs/execute/delete_child/read_attributes/write_attributes/delete/read_acl/write_acl/write_owner/synchronize:allow nt authority\system:read_data/write_data/append_data/read_named_attrs/write_named_attrs/execute/delete_child/read_attributes/write_attributes/delete/read_acl/write_acl/write_owner/synchronize:allow builtin\users:read_data/read_named_attrs/execute/read_attributes/read_acl/synchronize:allow nt authority\authenticated users:read_data/write_data/append_data/read_named_attrs/write_named_attrs/execute/read_attributes/write_attributes/delete/read_acl/synchronize:allow c:\code\jthink\opensrc\jaudiotagger>attrib c:\code\jthink\opensrc\jaudiotagger\testdata\test157.dsf r c:\code\jthink\opensrc\jaudiotagger\testdata\test157.dsf
update dont have conclusion thought information useful.
i running code in intellij ide without ide run program administrator option enabled, enabling did cause java application administrator privileges.
interesting file didn't add deny privileges, disabled inherit permissions , remove read permissions groups. when ran user without run admin enabled not read file , code not output information
aclfileattributeview view = files.getfileattributeview(path, aclfileattributeview.class); if (view != null) { sb.append("owner:"+view.getowner().getname()+"**"); (aclentry acl : view.getacl()) { sb.append(acl.principal()+"**"); for(aclentrypermission aep:acl.permissions()) { sb.append(aep.tostring() + "**"); } } }
but when run run program adminstrator enabled still couldnt read file, above code did output of permissions follows:
owner:builtin\administrators
nt authority\system:write_data/append_data/write_named_attrs/write_attributes/synchronize:allow pclaptop\paul:write_data/append_data/write_named_attrs/write_attributes/synchronize:allow builtin\administrators:write_data/append_data/write_named_attrs/write_attributes/synchronize:allow
as can see though administrators
not have read
or read permissions
options can output permissions whereas before couldn't, perhaps due builtin/administraor being returned owner.
try reading this: https://docs.oracle.com/javase/tutorial/essential/io/check.html
it states that, files.exists(path)
returning false not mean not exist, yeah seem there permission problem. try files.notexists(path)
, see returns. if false means can not determined whether file exists, if returns true, there problem in code.
try running file command line instead of netbeans. if don't know how can search google, there tons of stuff on this, want compile .java file javac myfile.java
, run java myfile
. normal command prompt , 1 open administrator , see get.
Comments
Post a Comment