Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Methods](https://developer.android.com/reference/java/nio/file/attribute/PosixFilePermissions#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/java/nio/file/attribute/PosixFilePermissions#inhmethods)

# PosixFilePermissions

` public final class PosixFilePermissions `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | java.nio.file.attribute.PosixFilePermissions |

<br />

*** ** * ** ***

This class consists exclusively of static methods that operate on sets of `https://developer.android.com/reference/java/nio/file/attribute/PosixFilePermission` objects.

## Summary

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

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Public methods

### asFileAttribute

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static FileAttribute<Set<PosixFilePermission>> asFileAttribute (Set<PosixFilePermission> perms)
```

Creates a `https://developer.android.com/reference/java/nio/file/attribute/FileAttribute`, encapsulating a copy of the given file permissions, suitable for passing to the `https://developer.android.com/reference/java/nio/file/Files#createFile(java.nio.file.Path,%20java.nio.file.attribute.FileAttribute<?>[])` or `https://developer.android.com/reference/java/nio/file/Files#createDirectory(java.nio.file.Path,%20java.nio.file.attribute.FileAttribute<?>[])` methods.

<br />

| Parameters ||
|---|---|
| `perms` | `Set`: the set of permissions <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/nio/file/attribute/FileAttribute<https://developer.android.com/reference/java/util/Set<https://developer.android.com/reference/java/nio/file/attribute/PosixFilePermission>>` | an attribute encapsulating the given file permissions with `https://developer.android.com/reference/java/nio/file/attribute/FileAttribute#name()` `"posix:permissions"` <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/ClassCastException` | if the set contains elements that are not of type `PosixFilePermission` |

### fromString

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static Set<PosixFilePermission> fromString (String 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 />

<br />

| Parameters ||
|---|---|
| `perms` | `String`: string representing a set of permissions <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/util/Set<https://developer.android.com/reference/java/nio/file/attribute/PosixFilePermission>` | the resulting set of permissions <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if the string cannot be converted to a set of permissions |

**See also:**

- `https://developer.android.com/reference/java/nio/file/attribute/PosixFilePermissions#toString(java.util.Set<java.nio.file.attribute.PosixFilePermission>)`

### toString

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public static String toString (Set<PosixFilePermission> perms)
```

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

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

<br />

| Parameters ||
|---|---|
| `perms` | `Set`: the set of permissions <br /> |

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the string representation of the permission set <br /> |