# PosixFilePermissions

public final class **PosixFilePermissions** extends [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)  
This class consists exclusively of static methods that operate on sets of
`https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/attribute/PosixFilePermission.html` objects.

### Public Method Summary

|---|---|
| static [FileAttribute](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/attribute/FileAttribute.html)\<[Set](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Set.html)\<[PosixFilePermission](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/attribute/PosixFilePermission.html)\>\> | [asFileAttribute](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/attribute/PosixFilePermissions.html#asFileAttribute(java.util.Set<java.nio.file.attribute.PosixFilePermission>))([Set](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Set.html)\<[PosixFilePermission](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/attribute/PosixFilePermission.html)\> perms) Creates a `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/attribute/FileAttribute.html`, encapsulating a copy of the given file permissions, suitable for passing to the `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/Files.html#createFile(java.nio.file.Path,%20java.nio.file.attribute.FileAttribute<?>...)` or `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/Files.html#createDirectory(java.nio.file.Path,%20java.nio.file.attribute.FileAttribute<?>...)` methods. |
| static [Set](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Set.html)\<[PosixFilePermission](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/attribute/PosixFilePermission.html)\> | [fromString](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/attribute/PosixFilePermissions.html#fromString(java.lang.String))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) perms) Returns the set of permissions corresponding to a given `String` representation. |
| static [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/attribute/PosixFilePermissions.html#toString(java.util.Set<java.nio.file.attribute.PosixFilePermission>))([Set](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Set.html)\<[PosixFilePermission](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/attribute/PosixFilePermission.html)\> perms) Returns the `String` representation of a set of permissions. |

### Inherited Method Summary

From class [java.lang.Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)

|---|---|
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [clone](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#clone())() Creates and returns a copy of this `Object`. |
| boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj) Compares this instance with the specified object and indicates if they are equal. |
| void | [finalize](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#finalize())() Invoked when the garbage collector has detected that this instance is no longer reachable. |
| final [Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<?\> | [getClass](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#getClass())() Returns the unique instance of `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html` that represents this object's class. |
| int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#hashCode())() Returns an integer hash code for this object. |
| final void | [notify](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notify())() Causes a thread which is waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| final void | [notifyAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notifyAll())() Causes all threads which are waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#toString())() Returns a string containing a concise, human-readable description of this object. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long,%20int))(long timeout, int nanos) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long))(long timeout) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait())() Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object. |

## Public Methods

#### public static [FileAttribute](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/attribute/FileAttribute.html)\<[Set](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Set.html)\<[PosixFilePermission](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/attribute/PosixFilePermission.html)\>\>
**asFileAttribute**
([Set](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Set.html)\<[PosixFilePermission](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/attribute/PosixFilePermission.html)\> perms)

Creates a `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/attribute/FileAttribute.html`, encapsulating a copy of the given file
permissions, suitable for passing to the `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/Files.html#createFile(java.nio.file.Path,%20java.nio.file.attribute.FileAttribute<?>...)` or `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/Files.html#createDirectory(java.nio.file.Path,%20java.nio.file.attribute.FileAttribute<?>...)`
methods.

##### Parameters

| perms | the set of permissions |
|---|---|

##### Returns

- an attribute encapsulating the given file permissions with `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/attribute/FileAttribute.html#name()` `"posix:permissions"`

##### Throws

| [ClassCastException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/ClassCastException.html) | if the set contains elements that are not of type `PosixFilePermission` |
|---|---|

#### public static [Set](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Set.html)\<[PosixFilePermission](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/attribute/PosixFilePermission.html)\>
**fromString**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) perms)

Returns the set of permissions corresponding to a given `String`
representation.

The `perms` parameter is a `String` representing the
permissions. It has 9 characters that are interpreted as three sets of
three. The first set refers to the owner's permissions; the next to the
group permissions and the last to others. Within each set, the first
character is `'r'` to indicate permission to read, the second
character is `'w'` to indicate permission to write, and the third
character is `'x'` for execute permission. Where a permission is
not set then the corresponding character is set to `'-'`.

**Usage Example:**
Suppose we require the set of permissions that indicate the owner has read,
write, and execute permissions, the group has read and execute permissions
and others have none.

```
   Set<PosixFilePermission> perms = PosixFilePermissions.fromString("rwxr-x---");
 
```

<br />

##### Parameters

| perms | string representing a set of permissions |
|---|---|

##### Returns

- the resulting set of permissions

##### Throws

| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if the string cannot be converted to a set of permissions |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/attribute/PosixFilePermissions.html#toString(java.util.Set<java.nio.file.attribute.PosixFilePermission>)`

#### public static [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html)
**toString**
([Set](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Set.html)\<[PosixFilePermission](https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/attribute/PosixFilePermission.html)\> perms)

Returns the `String` representation of a set of permissions. It
is guaranteed that the returned `String` can be parsed by the
`https://developers.google.com/j2objc/javadoc/jre/reference/java/nio/file/attribute/PosixFilePermissions.html#fromString(java.lang.String)` method.

If the set contains `null` or elements that are not of type
`PosixFilePermission` then these elements are ignored.

##### Parameters

| perms | the set of permissions |
|---|---|

##### Returns

- the string representation of the permission set