StandardJavaFileManager (Java SE 15 & JDK 15) (original) (raw)

All Superinterfaces:

[AutoCloseable](../../../java.base/java/lang/AutoCloseable.html "interface in java.lang"), [Closeable](../../../java.base/java/io/Closeable.html "interface in java.io"), [Flushable](../../../java.base/java/io/Flushable.html "interface in java.io"), [JavaFileManager](JavaFileManager.html "interface in javax.tools"), [OptionChecker](OptionChecker.html "interface in javax.tools")


public interface StandardJavaFileManager extends JavaFileManager

File manager based on java.io.File and java.nio.file.Path. A common way to obtain an instance of this class is usinggetStandardFileManager, for example:

JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<JavaFileObject>(); StandardJavaFileManager fm = compiler.getStandardFileManager(diagnostics, null, null);

This file manager creates file objects representing regularfiles,zip file entries, or entries in similar file system based containers. Any file object returned from a file manager implementing this interface must observe the following behavior:

According to these rules, the following URIs, for example, are allowed:

Whereas these are not (reason in parentheses):

All implementations of this interface must support Path objects representing files in the default file system. It is recommended that implementations should support Path objects from any filesystem.

API Note:

Some methods on this interface take a Collection<? extends Path> instead of Iterable<? extends Path>. This is to prevent the possibility of accidentally calling the method with a single Path as such an argument, because althoughPath implements Iterable<Path>, it would almost never be correct to call these methods with a single Path and have it be treated as an Iterable of its components.

Since:

1.6

Modifier and Type Method Description
default Path asPath​(FileObject file) Returns the path, if any, underlying this file object (optional operation).
Iterable<? extends JavaFileObject> getJavaFileObjects​(File... files) Returns file objects representing the given files.
Iterable<? extends JavaFileObject> getJavaFileObjects​(String... names) Returns file objects representing the given file names.
default Iterable<? extends JavaFileObject> getJavaFileObjects​(Path... paths) Returns file objects representing the given paths.
Iterable<? extends JavaFileObject> getJavaFileObjectsFromFiles​(Iterable<? extends File> files) Returns file objects representing the given files.
default Iterable<? extends JavaFileObject> getJavaFileObjectsFromPaths​(Iterable<? extends Path> paths) Deprecated.
default Iterable<? extends JavaFileObject> getJavaFileObjectsFromPaths​(Collection<? extends Path> paths) Returns file objects representing the given paths.
Iterable<? extends JavaFileObject> getJavaFileObjectsFromStrings​(Iterable<String> names) Returns file objects representing the given file names.
Iterable<? extends File> getLocation​(JavaFileManager.Location location) Returns the search path associated with the given location.
default Iterable<? extends Path> getLocationAsPaths​(JavaFileManager.Location location) Returns the search path associated with the given location.
boolean isSameFile​(FileObject a,FileObject b) Compares two file objects and return true if they represent the same canonical file, zip file entry, or entry in any file system based container.
void setLocation​(JavaFileManager.Location location,Iterable<? extends File> files) Associates the given search path with the given location.
default void setLocationForModule​(JavaFileManager.Location location,String moduleName,Collection<? extends Path> paths) Associates the given search path with the given module and location, which must be a module-oriented or output location.
default void setLocationFromPaths​(JavaFileManager.Location location,Collection<? extends Path> paths) Associates the given search path with the given location.
default void setPathFactory​(StandardJavaFileManager.PathFactory f) Specify a factory that can be used to generate a path from a string, or series of strings.

Methods declared in interface javax.tools.JavaFileManager

[close](JavaFileManager.html#close%28%29), [contains](JavaFileManager.html#contains%28javax.tools.JavaFileManager.Location,javax.tools.FileObject%29), [flush](JavaFileManager.html#flush%28%29), [getClassLoader](JavaFileManager.html#getClassLoader%28javax.tools.JavaFileManager.Location%29), [getFileForInput](JavaFileManager.html#getFileForInput%28javax.tools.JavaFileManager.Location,java.lang.String,java.lang.String%29), [getFileForOutput](JavaFileManager.html#getFileForOutput%28javax.tools.JavaFileManager.Location,java.lang.String,java.lang.String,javax.tools.FileObject%29), [getJavaFileForInput](JavaFileManager.html#getJavaFileForInput%28javax.tools.JavaFileManager.Location,java.lang.String,javax.tools.JavaFileObject.Kind%29), [getJavaFileForOutput](JavaFileManager.html#getJavaFileForOutput%28javax.tools.JavaFileManager.Location,java.lang.String,javax.tools.JavaFileObject.Kind,javax.tools.FileObject%29), [getLocationForModule](JavaFileManager.html#getLocationForModule%28javax.tools.JavaFileManager.Location,java.lang.String%29), [getLocationForModule](JavaFileManager.html#getLocationForModule%28javax.tools.JavaFileManager.Location,javax.tools.JavaFileObject%29), [getServiceLoader](JavaFileManager.html#getServiceLoader%28javax.tools.JavaFileManager.Location,java.lang.Class%29), [handleOption](JavaFileManager.html#handleOption%28java.lang.String,java.util.Iterator%29), [hasLocation](JavaFileManager.html#hasLocation%28javax.tools.JavaFileManager.Location%29), [inferBinaryName](JavaFileManager.html#inferBinaryName%28javax.tools.JavaFileManager.Location,javax.tools.JavaFileObject%29), [inferModuleName](JavaFileManager.html#inferModuleName%28javax.tools.JavaFileManager.Location%29), [list](JavaFileManager.html#list%28javax.tools.JavaFileManager.Location,java.lang.String,java.util.Set,boolean%29), [listLocationsForModules](JavaFileManager.html#listLocationsForModules%28javax.tools.JavaFileManager.Location%29)