public final class FileLocator extends AbstractLocator
A concrete Locator
class that represents files.
Instances of this class can be initialized with either a File
object or with the name of a file. Based on this data the locator methods are
implemented in an appropriate way.
Note that this class does not check whether the passed in file exists. So if an input stream is to be obtained for this file, it is possible that a file not found exception gets thrown.
Instances of this class are created using the getInstance()
factory methods. They are immutable and thus can be shared between multiple
threads.
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj)
Compares this object with another one.
|
File |
getFile()
Returns the represented file resource.
|
String |
getFileName()
Returns the name of the represented file.
|
static FileLocator |
getInstance(File file)
Returns a
FileLocator instance for the specified file. |
static FileLocator |
getInstance(String fileName)
Returns a
FileLocator instance for the specified file name. |
URL |
getURL()
Returns the URL for the represented file.
|
int |
hashCode()
Returns a hash code for this object.
|
String |
toString()
Returns a string representation for this object.
|
getInputStream
public static FileLocator getInstance(File file)
FileLocator
instance for the specified file.file
- the file (must not be null)FileLocator
instance for this fileIllegalArgumentException
- if the file is nullpublic static FileLocator getInstance(String fileName)
FileLocator
instance for the specified file name.fileName
- the file name (must not be null)FileLocator
instance for this fileIllegalArgumentException
- if the file name is nullpublic URL getURL()
LocatorException
- if an error occurspublic File getFile()
getFile
in interface Locator
getFile
in class AbstractLocator
public String getFileName()
public boolean equals(Object obj)
public int hashCode()
Copyright © 2016 The JGUIraffe Team. All rights reserved.