You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@netbeans.apache.org by slipbits <sl...@slipbits.com> on 2020/07/06 15:37:13 UTC

Issue with recognizing functions

I am trying to create files/directories and to assign attributes to 
them. I would like my software to play on multiple OS's and I am trying 
to find the Java way of identifying OS specific attributes. Two issues 
came up. In one, there is no discussion of Windows attributes. I have 
assumed that they are the same as Posix. In the second case, I found a 
method (fromString()) which looks like a useful thing to know but can't 
get either NB12 or OpenBeans to recognize it and I'm stumped.

The test code is:

package test;

import java.nio.file.attribute.PosixFilePermission.fromString;
import java.nio.file.attribute.PosixFilePermission;
import java.util.Set;

public class test {
    public static void main(String[] args) {
      Set<PosixFilePermission> attr = fromString("rwxrw----");
      System.out.println(attr.toString());
    }; //  void main(String[] args)
}; // class test

I have tried to fix this with:

import java.nio.file.attribute.PosixFilePermission.*; and

Set<PosixFilePermission> attr = 
java.nio.file.attribute.PosixFilePermission.fromString("rwxrw----");

without success. The puzzler is that the Java tutorial 
(https://docs.oracle.com/javase/tutorial/essential/io/fileAttr.html#dos) 
and the Java 1.8 documentation both seem to say that any of the above 
should work.

Can anyone please help. Are the Windows attributes the same as Posix, 
and how can I use fromString()?




Re: Issue with recognizing functions

Posted by slipbits <sl...@slipbits.com>.
Thanks


On 7/6/2020 9:39 AM, HRH wrote:
> This statement in your codeSystem.out.println(attr.toString()); will 
> not print the permissions. The toString() operation on 
> PosixFilePermissions class requires a parameter. Here is the method 
> signature:
> PosixFilePermissions.toString​(Set<PosixFilePermission> perms)
>
>
>
>
>
> On Monday, July 6, 2020, 8:08:10 PM GMT+4:30, slipbits 
> <sl...@slipbits.com> wrote:
>
>
> I am trying to create files/directories and to assign attributes to 
> them. I would like my software to play on multiple OS's and I am 
> trying to find the Java way of identifying OS specific attributes. Two 
> issues came up. In one, there is no discussion of Windows attributes. 
> I have assumed that they are the same as Posix. In the second case, I 
> found a method (fromString()) which looks like a useful thing to know 
> but can't get either NB12 or OpenBeans to recognize it and I'm stumped.
>
> The test code is:
>
> package test;
>
> import java.nio.file.attribute.PosixFilePermission.fromString;
> import java.nio.file.attribute.PosixFilePermission;
> import java.util.Set;
>
> public class test {
>    public static void main(String[] args) {
>      Set<PosixFilePermission> attr = fromString("rwxrw----");
>      System.out.println(attr.toString());
>    }; //  void main(String[] args)
> }; // class test
>
> I have tried to fix this with:
>
> import java.nio.file.attribute.PosixFilePermission.*; and
>
> Set<PosixFilePermission> attr = 
> java.nio.file.attribute.PosixFilePermission.fromString("rwxrw----");
>
> without success. The puzzler is that the Java tutorial 
> (https://docs.oracle.com/javase/tutorial/essential/io/fileAttr.html#dos) 
> and the Java 1.8 documentation both seem to say that any of the above 
> should work.
>
> Can anyone please help. Are the Windows attributes the same as Posix, 
> and how can I use fromString()?
>
>
>

Re: Issue with recognizing functions

Posted by HRH <hr...@yahoo.com.INVALID>.
 This statement in your code System.out.println(attr.toString()); will not print the permissions. The toString() operation on PosixFilePermissions class requires a parameter. Here is the method signature:PosixFilePermissions.toString​(Set<PosixFilePermission> perms) 




 
    On Monday, July 6, 2020, 8:08:10 PM GMT+4:30, slipbits <sl...@slipbits.com> wrote:  
 
   
I am trying to create files/directories and to assign attributes to them. I would like my software to play on multiple OS's and I am trying to find the Java way of identifying OS specific attributes. Two issues came up. In one, there is no discussion of Windows attributes. I have assumed that they are the same as Posix. In the second case, I found a method (fromString()) which looks like a useful thing to know but can't get either NB12 or OpenBeans to recognize it and I'm stumped. 
 
 
The test code is:
 
package test;
 
 import java.nio.file.attribute.PosixFilePermission.fromString;
 import java.nio.file.attribute.PosixFilePermission;
 import java.util.Set;
 
 public class test {
    public static void main(String[] args) {
      Set<PosixFilePermission> attr = fromString("rwxrw----");
      System.out.println(attr.toString());
    }; //  void main(String[] args) 
 }; // class test
 
 
 
I have tried to fix this with:
 
import java.nio.file.attribute.PosixFilePermission.*; and
 
 Set<PosixFilePermission> attr = java.nio.file.attribute.PosixFilePermission.fromString("rwxrw----");
 
 
without success. The puzzler is that the Java tutorial (https://docs.oracle.com/javase/tutorial/essential/io/fileAttr.html#dos) and the Java 1.8 documentation both seem to say that any of the above should work. 
 
 
Can anyone please help. Are the Windows attributes the same as Posix, and how can I use fromString()?