Which method is used to test whether the application can modify the file denoted by this abstract pathname?

Skip to main content

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

File.List Method

  • Reference

Definition

In this article

Overloads

List()

Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname.

List(IFilenameFilter)

Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter.

List()

Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname.

[Android.Runtime.Register("list", "()[Ljava/lang/String;", "GetListHandler")]
public virtual string[]? List ();
[<Android.Runtime.Register("list", "()[Ljava/lang/String;", "GetListHandler")>]
abstract member List : unit -> string[]
override this.List : unit -> string[]

Returns

String[]

An array of strings naming the files and directories in the directory denoted by this abstract pathname. The array will be empty if the directory is empty. Returns null if this abstract pathname does not denote a directory, or if an I/O error occurs.

Attributes

Remarks

Java documentation for java.io.File.list().

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.

Applies to

List(IFilenameFilter)

Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter.

[Android.Runtime.Register("list", "(Ljava/io/FilenameFilter;)[Ljava/lang/String;", "GetList_Ljava_io_FilenameFilter_Handler")]
public virtual string[]? List (Java.IO.IFilenameFilter? filter);
[<Android.Runtime.Register("list", "(Ljava/io/FilenameFilter;)[Ljava/lang/String;", "GetList_Ljava_io_FilenameFilter_Handler")>]
abstract member List : Java.IO.IFilenameFilter -> string[]
override this.List : Java.IO.IFilenameFilter -> string[]

Parameters

Returns

String[]

An array of strings naming the files and directories in the directory denoted by this abstract pathname that were accepted by the given filter. The array will be empty if the directory is empty or if no names were accepted by the filter. Returns null if this abstract pathname does not denote a directory, or if an I/O error occurs.

Attributes

Remarks

Java documentation for java.io.File.list(java.io.FilenameFilter).

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.

Applies to

Skip to main content

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

File Class

  • Reference

Definition

An abstract representation of file and directory pathnames.

In this article

[Android.Runtime.Register("java/io/File", DoNotGenerateAcw=true)]
public class File : Java.Lang.Object, IDisposable, Java.Interop.IJavaPeerable, Java.IO.ISerializable, Java.Lang.IComparable
[<Android.Runtime.Register("java/io/File", DoNotGenerateAcw=true)>]
type File = class
    inherit Object
    interface ISerializable
    interface IJavaObject
    interface IDisposable
    interface IJavaPeerable
    interface IComparable
InheritanceAttributesImplements

Remarks

Java documentation for java.io.File.

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.

Constructors

File(File, String)

Creates a new File instance from a parent abstract pathname and a child pathname string.

File(IntPtr, JniHandleOwnership)

A constructor used when creating managed representations of JNI objects; called by the runtime.

File(String)

Creates a new File instance by converting the given pathname string into an abstract pathname.

File(String, String)

Creates a new File instance from a parent pathname string and a child pathname string.

File(URI)

Creates a new File instance by converting the given file: URI into an abstract pathname.

Properties

AbsoluteFile

Returns the absolute form of this abstract pathname.

AbsolutePath

Returns the absolute path of this file.

CanonicalFile

Returns the canonical form of this abstract pathname.

CanonicalPath

Returns the canonical pathname string of this abstract pathname.

Class

Returns the runtime class of this Object.

(Inherited from Object)
FreeSpace

Returns the number of unallocated bytes in the partition "#partName">named by this abstract path name.

Handle

The handle to the underlying Android instance.

(Inherited from Object)
IsAbsolute

Tests whether this abstract pathname is absolute.

IsDirectory

Tests whether the file denoted by this abstract pathname is a directory.

IsFile

Tests whether the file denoted by this abstract pathname is a normal file.

IsHidden

Tests whether the file named by this abstract pathname is a hidden file.

JniIdentityHashCode (Inherited from Object)
JniPeerMembers
Name

Returns the name of the file or directory denoted by this abstract pathname.

Parent

Returns the pathname string of this abstract pathname's parent, or null if this pathname does not name a parent directory.

ParentFile

Returns the abstract pathname of this abstract pathname's parent, or null if this pathname does not name a parent directory.

Path

Converts this abstract pathname into a pathname string.

PathSeparator

The system-dependent path-separator character, represented as a string for convenience.

PathSeparatorChar

The system-dependent path-separator character.

PeerReference (Inherited from Object)
Separator

The system-dependent default name-separator character, represented as a string for convenience.

SeparatorChar

The system-dependent default name-separator character.

ThresholdClass

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

ThresholdType

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

TotalSpace

Returns the size of the partition "#partName">named by this abstract pathname.

UsableSpace

Returns the number of bytes available to this virtual machine on the partition "#partName">named by this abstract pathname.

Methods

CanExecute()

Tests whether the application can execute the file denoted by this abstract pathname.

CanRead()

Tests whether the application can read the file denoted by this abstract pathname.

CanWrite()

Tests whether the application can modify the file denoted by this abstract pathname.

Clone()

Creates and returns a copy of this object.

(Inherited from Object)
CompareTo(File)

Compares two abstract pathnames lexicographically.

CreateNewFile()

Atomically creates a new, empty file named by this abstract pathname if and only if a file with this name does not yet exist.

CreateTempFile(String, String)

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

CreateTempFile(String, String, File)

Creates a new empty file in the specified directory, using the given prefix and suffix strings to generate its name.

Delete()

Deletes the file or directory denoted by this abstract pathname.

DeleteOnExit()

Requests that the file or directory denoted by this abstract pathname be deleted when the virtual machine terminates.

Dispose() (Inherited from Object)
Dispose(Boolean) (Inherited from Object)
Equals(Object)

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

(Inherited from Object)
Exists()

Tests whether the file or directory denoted by this abstract pathname exists.

GetHashCode()

Returns a hash code value for the object.

(Inherited from Object)
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)
LastModified()

Returns the time that the file denoted by this abstract pathname was last modified.

Length()

Returns the length of the file denoted by this abstract pathname.

List()

Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname.

List(IFilenameFilter)

Returns an array of strings naming the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter.

ListAsync()
ListAsync(IFilenameFilter)
ListFiles()

Returns an array of abstract pathnames denoting the files in the directory denoted by this abstract pathname.

ListFiles(IFileFilter)

Returns an array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter.

ListFiles(IFilenameFilter)

Returns an array of abstract pathnames denoting the files and directories in the directory denoted by this abstract pathname that satisfy the specified filter.

ListFilesAsync()
ListFilesAsync(IFileFilter)
ListFilesAsync(IFilenameFilter)
ListRoots()

Returns the file system roots.

ListRootsAsync()
Mkdir()

Creates the directory named by this abstract pathname.

Mkdirs()

Creates the directory named by this abstract pathname, including any necessary but nonexistent parent directories.

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)
RenameTo(File)

Renames the file denoted by this abstract pathname.

SetExecutable(Boolean)

A convenience method to set the owner's execute permission for this abstract pathname.

SetExecutable(Boolean, Boolean)

Sets the owner's or everybody's execute permission for this abstract pathname.

SetHandle(IntPtr, JniHandleOwnership)

Sets the Handle property.

(Inherited from Object)
SetLastModified(Int64)

Sets the last-modified time of the file or directory named by this abstract pathname.

SetReadable(Boolean)

A convenience method to set the owner's read permission for this abstract pathname.

SetReadable(Boolean, Boolean)

Sets the owner's or everybody's read permission for this abstract pathname.

SetReadOnly()

Marks the file or directory named by this abstract pathname so that only read operations are allowed.

SetWritable(Boolean)

A convenience method to set the owner's write permission for this abstract pathname.

SetWritable(Boolean, Boolean)

Sets the owner's or everybody's write permission for this abstract pathname.

ToArray<T>() (Inherited from Object)
ToPath()

Returns a Path java.nio.file.Path object constructed from the this abstract path.

ToString()

Returns a string representation of the object.

(Inherited from Object)
ToURI()

Constructs a file: URI that represents this abstract pathname.

ToURL()

Obsolete.

Converts this abstract pathname into a file: URL.

UnregisterFromRuntime() (Inherited from Object)
Wait()

Causes the current thread to wait until another thread invokes the java.lang.Object#notify() method or the java.lang.Object#notifyAll() method for this object.

(Inherited from Object)
Wait(Int64)

Causes the current thread to wait until either another thread invokes the java.lang.Object#notify() method or the java.lang.Object#notifyAll() method for this object, or a specified amount of time has elapsed.

(Inherited from Object)
Wait(Int64, Int32)

Causes the current thread to wait until another thread invokes the java.lang.Object#notify() method or the java.lang.Object#notifyAll() method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.

(Inherited from Object)

Explicit Interface Implementations

IComparable.CompareTo(Object)
IJavaPeerable.Disposed() (Inherited from Object)
IJavaPeerable.DisposeUnlessReferenced() (Inherited from Object)
IJavaPeerable.Finalized() (Inherited from Object)
IJavaPeerable.JniManagedPeerState (Inherited from Object)
IJavaPeerable.SetJniIdentityHashCode(Int32) (Inherited from Object)
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) (Inherited from Object)
IJavaPeerable.SetPeerReference(JniObjectReference) (Inherited from Object)

Extension Methods

Applies to

Which of the following method is used to check whether the file denoted by the pathname is a directory?

The isDirectory method can be used to test if the file denoted by the provided name is a directory, while the isFile method can be used to test if the file denoted by the provided name is a file. And, we can use the exists method to test whether a directory or file already exists on the system.

Which method is used to test a element is a file or directory?

File isFile() method in Java with Examples This function determines whether the is a file or Directory denoted by the abstract filename is File or not. The function returns true if the abstract file path is File else returns false.

What is abstract pathname?

An abstract pathname has two components: An optional system-dependent prefix string, such as a disk-drive specifier, "/" for the UNIX root directory, or "\\" for a Microsoft Windows UNC pathname, and. A sequence of zero or more string names.

Which of the following method automatically creates a new empty file named by this abstract pathname?

public boolean createNewFile() throws IOException Atomically creates a new, empty file named by this abstract pathname if and only if a file with this name does not yet exist.