Class FileTypeFilter
A named group of file types a file dialog offers, such as "PNG Image" or "Text Documents".
A filter can name the same types three ways, and each platform reads the one it understands: desktop dialogs and the fallback chooser use the extensions, Android and the browser use the MIME types, and iOS and macOS use the Uniform Type Identifiers when given, deriving them from the extensions otherwise. Supplying extensions alone works everywhere.
FileTypeFilter png = new FileTypeFilter("PNG Image")
.extensions("png").mimeTypes("image/png").utTypes("public.png");
-
Constructor Summary
ConstructorsConstructorDescriptionFileTypeFilter(String label) Creates a filter with the label the dialog shows for it. -
Method Summary
Modifier and TypeMethodDescriptionbooleanacceptsName(String name) Checks whether a file name ends with one of this filter's extensions.extensions(String... ext) Adds file extensions, with or without the leading dot.String[]The extensions, without leading dots.getLabel()The label the dialog shows.String[]The MIME types.String[]The Uniform Type Identifiers.Adds MIME types such as"image/png"or"image/*".Adds Apple Uniform Type Identifiers such as"public.png".
-
Constructor Details
-
FileTypeFilter
Creates a filter with the label the dialog shows for it.
Parameters
label: the human readable name of the filter
-
-
Method Details
-
extensions
Adds file extensions, with or without the leading dot.
Parameters
ext: extensions such as"png"or".jpg"
Returns
this filter
-
mimeTypes
Adds MIME types such as
"image/png"or"image/*".Parameters
types: the MIME types
Returns
this filter
-
utTypes
Adds Apple Uniform Type Identifiers such as
"public.png". Ignored outside iOS and macOS.Parameters
types: the type identifiers
Returns
this filter
-
getLabel
The label the dialog shows.
Returns
the label
-
getExtensions
The extensions, without leading dots.
Returns
a copy of the extension list
-
getMimeTypes
The MIME types.
Returns
a copy of the MIME type list
-
getUtTypes
The Uniform Type Identifiers.
Returns
a copy of the identifier list
-
acceptsName
Checks whether a file name ends with one of this filter's extensions. A filter without extensions accepts every name.
Parameters
name: the file name or path
Returns
true if the name matches
-