br.com.objectos.fs
Class LocalFs

java.lang.Object
  extended by br.com.objectos.fs.LocalFs

public final class LocalFs
extends Object

Provides static methods for obtaining PathName instances, such as directories and files, from the local file system. The local file system is the one accessible to the Java virtual machine process.

Since:
2

Method Summary
static Directory getDirectory(File file)
          Returns an existing directory whose pathname is given by the specified java.io.File.
static Directory getDirectory(String first, String... more)
          Returns an existing directory whose pathname is given by combining all of the specified names.
static RegularFile getRegularFile(Resource resource)
          Returns an existing file given by the specified ClassLoader resource.
static RegularFile getRegularFile(String first, String... more)
          Returns an existing file whose pathname is given by combining all of the specified names.
static RegularFile getRegularFile(URI uri)
          Returns an existing file whose pathname is given by the specified java.net.URI.
static ResolvedPath resolve(File file)
          Returns a ResolvedPath by converting a java.io.File.
static ResolvedPath resolve(String first, String... more)
          Returns a ResolvedPath whose pathname is given by combining all of the specified names.
static ResolvedPath resolve(URI uri)
          Returns a ResolvedPath by converting a java.net.URI.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getDirectory

public static Directory getDirectory(File file)
                              throws NotFoundException,
                                     NotDirectoryException,
                                     IOException
Returns an existing directory whose pathname is given by the specified java.io.File.

This is a convenience method for which the implementation is equivalent to:

     ResolvedPath path = LocalFs.resolve(file);
     return path.toDirectory();

Parameters:
file - the java.io.File instance
Returns:
an existing directory
Throws:
NotFoundException - if the pathname does not exist
NotDirectoryException - if the pathname exists but it is not a directory (is a regular file for instance)
IOException - if an I/O error occurs
See Also:
ResolvedPath.toDirectory()

getDirectory

public static Directory getDirectory(String first,
                                     String... more)
                              throws NotFoundException,
                                     NotDirectoryException,
                                     IOException
Returns an existing directory whose pathname is given by combining all of the specified names.

This is a convenience method for which the implementation is equivalent to:

     ResolvedPath path = LocalFs.resolve(first, more);
     return path.toDirectory();

Parameters:
first - the first part of the pathname
more - the remaining parts of the pathname
Returns:
an existing directory
Throws:
NotFoundException - if the pathname does not exist
NotDirectoryException - if the pathname exists but it is not a directory (is a regular file for instance)
IOException - if an I/O error occurs
See Also:
ResolvedPath.toDirectory()

getRegularFile

public static RegularFile getRegularFile(Resource resource)
                                  throws NotFoundException,
                                         NotRegularFileException,
                                         IOException
Returns an existing file given by the specified ClassLoader resource.

This is a convenience method for which the implementation is equivalent to:

     URI uri = resource.toUri();
     ResolvedPath path = LocalFs.resolve(uri);
     return path.toRegularFile();

Parameters:
resource - a class loader resource
Returns:
an existing file
Throws:
NotFoundException - if the pathname does not exist
NotRegularFileException - if the pathname exists but it is not a file (is a directory for instance)
IOException - if an I/O error occurs
See Also:
ResolvedPath.toRegularFile()

getRegularFile

public static RegularFile getRegularFile(String first,
                                         String... more)
                                  throws NotFoundException,
                                         NotRegularFileException,
                                         IOException
Returns an existing file whose pathname is given by combining all of the specified names.

This is a convenience method for which the implementation is equivalent to:

     ResolvedPath path = LocalFs.resolve(first, more);
     return path.toRegularFile();

Parameters:
first - the first part of the pathname
more - the remaining parts of the pathname
Returns:
an existing file
Throws:
NotFoundException - if the pathname does not exist
NotRegularFileException - if the pathname exists but it is not a file (is a directory for instance)
IOException - if an I/O error occurs
See Also:
ResolvedPath.toRegularFile()

getRegularFile

public static RegularFile getRegularFile(URI uri)
                                  throws NotFoundException,
                                         NotRegularFileException,
                                         IOException
Returns an existing file whose pathname is given by the specified java.net.URI.

This is a convenience method for which the implementation is equivalent to:

     ResolvedPath path = LocalFs.resolve(uri);
     return path.toRegularFile();
 

Parameters:
uri - the java.net.URI instance
Returns:
an existing file
Throws:
NotFoundException - if the pathname does not exist
NotRegularFileException - if the pathname exists but it is not a file (is a directory for instance)
IOException - if an I/O error occurs
See Also:
ResolvedPath.toRegularFile()

resolve

public static ResolvedPath resolve(File file)
Returns a ResolvedPath by converting a java.io.File.

Parameters:
file - the java.io.File to convert
Returns:
a ResolvedPath

resolve

public static ResolvedPath resolve(String first,
                                   String... more)
Returns a ResolvedPath whose pathname is given by combining all of the specified names.

All of the specified names are combined together, in a system dependant manner, resulting in a pathname. This pathname is used to create the ResolvedPath instance.

Parameters:
first - the first part of the pathname
more - the remaining parts of the pathname
Returns:
a ResolvedPath

resolve

public static ResolvedPath resolve(URI uri)
Returns a ResolvedPath by converting a java.net.URI.

Parameters:
uri - the java.net.URI to convert
Returns:
a ResolvedPath


Copyright © 2021 Objectos Software LTDA. All rights reserved.