Files Class

Definition

This class consists exclusively of static methods that operate on files, directories, or other types of files.

[Android.Runtime.Register("java/nio/file/Files", ApiSince=26, DoNotGenerateAcw=true)]
public sealed class Files : Java.Lang.Object
[<Android.Runtime.Register("java/nio/file/Files", ApiSince=26, DoNotGenerateAcw=true)>]
type Files = class
    inherit Object
Inheritance
Attributes

Remarks

This class consists exclusively of static methods that operate on files, directories, or other types of files.

In most cases, the methods defined here will delegate to the associated file system provider to perform the file operations.

Added in 1.7.

Java documentation for java.nio.file.Files.

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Properties

Name Description
Class

Returns the runtime class of this Object.

(Inherited from Object)
Handle

The handle to the underlying Android instance.

(Inherited from Object)
JniIdentityHashCode

Gets the identity hash code assigned to this Java peer by the interop runtime.

(Inherited from Object)
JniManagedPeerState (Inherited from JavaObject)
JniPeerMembers
PeerReference

Gets the JNI object reference for this Java peer.

(Inherited from Object)
ThresholdClass

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from Object)
ThresholdType

This API supports the Mono for Android infrastructure and is not intended to be used directly from your code.

(Inherited from Object)

Methods

Name Description
Clone()

Creates and returns a copy of this object.

(Inherited from Object)
Construct(JniObjectReference, JniObjectReferenceOptions) (Inherited from JavaObject)
Copy(IPath, IPath, ICopyOption[])

Reads all bytes from an input stream and writes them to an output stream.

Copy(IPath, Stream)

Copies all bytes from a file to an output stream.

Copy(Stream, IPath, ICopyOption[])

Reads all bytes from an input stream and writes them to an output stream.

CreateDirectories(IPath, IFileAttribute[])

Creates a directory by creating all nonexistent parent directories first.

CreateDirectory(IPath, IFileAttribute[])

Creates a new directory.

CreateFile(IPath, IFileAttribute[])

Creates a new and empty file, failing if the file already exists.

CreateLink(IPath, IPath)

Creates a new link (directory entry) for an existing file (optional operation).

CreateSymbolicLink(IPath, IPath, IFileAttribute[])

Creates a symbolic link to a target (optional operation).

CreateTempDirectory(IPath, String, IFileAttribute[])

Creates a new directory in the default temporary-file directory, using the given prefix to generate its name.

CreateTempDirectory(String, IFileAttribute[])

Creates a new directory in the default temporary-file directory, using the given prefix to generate its name.

CreateTempFile(IPath, String, String, IFileAttribute[])

Creates an empty file in the default temporary-file directory, using the given prefix and suffix to generate its name.

CreateTempFile(String, String, IFileAttribute[])

Creates an empty file in the default temporary-file directory, using the given prefix and suffix to generate its name.

Delete(IPath)

Deletes a file.

DeleteIfExists(IPath)

Deletes a file if it exists.

Dispose()

Releases the resources held by this Java peer.

(Inherited from Object)
Dispose(Boolean)

Releases the resources held by this Java peer.

(Inherited from Object)
DisposeUnlessReferenced() (Inherited from JavaObject)
Equals(Object) (Inherited from JavaObject)
Equals(Object)

Indicates whether some other object is "equal to" this one.

(Inherited from Object)
Exists(IPath, LinkOption[])

Tests whether a file exists.

GetAttribute(IPath, String, LinkOption[])

Reads the value of a file attribute.

GetFileAttributeView(IPath, Class, LinkOption[])

Returns a file attribute view of a given type.

GetFileStore(IPath)

Returns the FileStore representing the file store where a file is located.

GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
GetLastModifiedTime(IPath, LinkOption[])

Returns a file's last modified time.

GetOwner(IPath, LinkOption[])

Returns the owner of a file.

GetPosixFilePermissions(IPath, LinkOption[])

Returns a file's POSIX file permissions.

IsDirectory(IPath, LinkOption[])

Tests whether a file is a directory.

IsExecutable(IPath)

Tests whether a file is executable.

IsHidden(IPath)

Tells whether or not a file is considered <em>hidden</em>.

IsReadable(IPath)

Tests whether a file is readable.

IsRegularFile(IPath, LinkOption[])

Tests whether a file is a regular file with opaque content.

IsSameFile(IPath, IPath)

Tests if two paths locate the same file.

IsSymbolicLink(IPath)

Tests whether a file is a symbolic link.

IsWritable(IPath)

Tests whether a file is writable.

JavaFinalize()

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

(Inherited from Object)
Move(IPath, IPath, ICopyOption[])

Move or rename a file to a target file.

NewBufferedReader(IPath, Charset)

Opens a file for reading, returning a BufferedReader that may be used to read text from the file in an efficient manner.

NewBufferedReader(IPath)

Opens a file for reading, returning a BufferedReader to read text from the file in an efficient manner.

NewBufferedWriter(IPath, Charset, IOpenOption[])

Opens or creates a file for writing, returning a BufferedWriter that may be used to write text to the file in an efficient manner.

NewBufferedWriter(IPath, IOpenOption[])

Opens or creates a file for writing, returning a BufferedWriter that may be used to write text to the file in an efficient manner.

NewByteChannel(IPath, ICollection<IOpenOption>, IFileAttribute[])

Opens or creates a file, returning a seekable byte channel to access the file.

NewByteChannel(IPath, IOpenOption[])

Opens or creates a file, returning a seekable byte channel to access the file.

NewDirectoryStream(IPath, IDirectoryStreamFilter)

Opens a directory, returning a DirectoryStream to iterate over all entries in the directory.

NewDirectoryStream(IPath, String)

Opens a directory, returning a DirectoryStream to iterate over the entries in the directory.

NewDirectoryStream(IPath)

Opens a directory, returning a DirectoryStream to iterate over all entries in the directory.

NewInputStream(IPath, IOpenOption[])

Opens a file, returning an input stream to read from the file.

NewOutputStream(IPath, IOpenOption[])

Opens or creates a file, returning an output stream that may be used to write bytes to the file.

NotExists(IPath, LinkOption[])

Tests whether the file located by this path does not exist.

Notify()

Wakes up a single thread that is waiting on this object's monitor.

(Inherited from Object)
NotifyAll()

Wakes up all threads that are waiting on this object's monitor.

(Inherited from Object)
ProbeContentType(IPath)

Probes the content type of a file.

ReadAllBytes(IPath)

Reads all the bytes from a file.

ReadAllLines(IPath, Charset)

Read all lines from a file.

ReadAllLines(IPath)

Read all lines from a file.

ReadAttributes(IPath, Class, LinkOption[])

Reads a file's attributes as a bulk operation.

ReadAttributes(IPath, String, LinkOption[])

Reads a file's attributes as a bulk operation.

ReadString(IPath, Charset)

Reads all characters from a file into a string, decoding from bytes to characters using the specified Charset charset.

ReadString(IPath)

Reads all content from a file into a string, decoding from bytes to characters using the StandardCharsets#UTF_8 UTF-8Charset charset.

ReadSymbolicLink(IPath)

Reads the target of a symbolic link (optional operation).

SetAttribute(IPath, String, Object, LinkOption[])

Sets the value of a file attribute.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetLastModifiedTime(IPath, FileTime)

Updates a file's last modified time attribute.

SetOwner(IPath, IUserPrincipal)

Updates the file owner.

SetPeerReference(JniObjectReference, JniObjectReferenceOptions) (Inherited from JavaObject)
SetPosixFilePermissions(IPath, ICollection<PosixFilePermission>)

Sets a file's POSIX permissions.

Size(IPath)

Returns the size of a file (in bytes).

ToArray<T>()

Creates a managed array from this Java array wrapper.

(Inherited from Object)
ToString()

Returns a string representation of the object.

(Inherited from Object)
UnregisterFromRuntime()

Unregisters this Java peer from the interop runtime.

(Inherited from Object)
Wait()

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed.

(Inherited from Object)
WalkFileTree(IPath, ICollection<FileVisitOption>, Int32, IFileVisitor)

Walks a file tree.

WalkFileTree(IPath, IFileVisitor)

Walks a file tree.

Write(IPath, Byte[], IOpenOption[])

Write lines of text to a file.

Write(IPath, IIterable, Charset, IOpenOption[])

Write lines of text to a file.

Write(IPath, IIterable, IOpenOption[])

Write lines of text to a file.

WriteString(IPath, ICharSequence, Charset, IOpenOption[])
WriteString(IPath, ICharSequence, IOpenOption[])
WriteString(IPath, String, Charset, IOpenOption[])
WriteString(IPath, String, IOpenOption[])

Explicit Interface Implementations

Name Description
IJavaPeerable.Disposed() (Inherited from JavaObject)
IJavaPeerable.Finalized() (Inherited from JavaObject)
IJavaPeerable.JniObjectReferenceControlBlock (Inherited from JavaObject)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from JavaObject)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from JavaObject)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from JavaObject)

Extension Methods

Name Description
GetJniTypeName(IJavaPeerable)

Gets the JNI name of the type of the instance self.

JavaAs<TResult>(IJavaPeerable)

Try to coerce self to type TResult, checking that the coercion is valid on the Java side.

JavaCast<TResult>(IJavaObject)

Performs an Android runtime-checked type conversion.

JavaCast<TResult>(IJavaObject)
TryJavaCast<TResult>(IJavaPeerable, TResult)

Try to coerce self to type TResult, checking that the coercion is valid on the Java side.

Applies to