public class VirtualLocalFile extends Object implements VirtualFile
VirtualLocalFile
class represents a source file in memory. Each VirtualLocalFile
instance
is given a parent that corresponds to a valid directory in the filesystem. Path
resolution is done as if VirtualLocalFile
instances represented real files in the filesystem.
You can not create an instance of the VirtualLocalFile
class directly. You must
use the VirtualLocalFileSystem
class to create them.
VirtualLocalFileSystem
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this
VirtualLocalFile object. |
boolean |
equals(Object obj)
Compares this object with the specified object.
|
InputStream |
getInputStream()
Returns the text in this
VirtualLocalFile object in an InputStream . |
long |
getLastModified()
Gets the last modified time of this
VirtualLocalFile object. |
String |
getMimeType()
Returns The MIME type of this
VirtualLocalFile object. |
String |
getName()
Gets the name of this
VirtualLocalFile object. |
String |
getNameForReporting()
Gets the name of this
VirtualLocalFile for error reporting. |
String |
getParent()
Gets the parent directory path of this
VirtualLocalFile object. |
String |
getURL()
Throws an
UnsupportedOperationException exception. |
int |
hashCode()
Returns the hash code of this
VirtualLocalFile object. |
boolean |
isDirectory()
Returns
true if this VirtualLocalFile object is a directory. |
boolean |
isTextBased()
Returns
true if the content of this VirtualLocalFile object is text based. |
VirtualFile |
resolve(String relativeStr)
Resolves the specified relative path to a
VirtualFile instance. |
long |
size()
Returns the length of the text in this
VirtualLocalFile object. |
byte[] |
toByteArray()
Returns the text in this
VirtualLocalFile object in an byte[] . |
String |
toString() |
public String getName()
VirtualLocalFile
object. This is sually a canonical path.getName
in interface VirtualFile
VirtualLocalFile
object.public String getNameForReporting()
VirtualLocalFile
for error reporting. This is usually a canonical path.getNameForReporting
in interface VirtualFile
getName()
public String getURL()
UnsupportedOperationException
exception.getURL
in interface VirtualFile
public String getParent()
VirtualLocalFile
object.getParent
in interface VirtualFile
public boolean isDirectory()
true
if this VirtualLocalFile
object is a directory. This method always returns false
.isDirectory
in interface VirtualFile
false
.public long size()
VirtualLocalFile
object.size
in interface VirtualFile
public String getMimeType()
VirtualLocalFile
object.getMimeType
in interface VirtualFile
public InputStream getInputStream() throws IOException
VirtualLocalFile
object in an InputStream
.
The text is converted into a byte stream based on UTF-8
encoding.getInputStream
in interface VirtualFile
InputStream
.IOException
- Thrown when an I/O error occurs.public byte[] toByteArray() throws IOException
VirtualLocalFile
object in an byte[]
.toByteArray
in interface VirtualFile
IOException
public long getLastModified()
VirtualLocalFile
object.getLastModified
in interface VirtualFile
public VirtualFile resolve(String relativeStr)
VirtualFile
instance.resolve
in interface SinglePathResolver
relativeStr
- The relative path to be resolved.VirtualFile
for relativeStr
.public void close()
VirtualLocalFile
object. This method does nothing.close
in interface VirtualFile
public boolean equals(Object obj)
equals
in interface VirtualFile
equals
in class Object
obj
- An Object.true
if obj == this
.public int hashCode()
VirtualLocalFile
object.hashCode
in interface VirtualFile
hashCode
in class Object
public boolean isTextBased()
true
if the content of this VirtualLocalFile
object is text based.
This method always returns true
.isTextBased
in interface VirtualFile
true
.Copyright © 2016 The Apache Software Foundation. All rights reserved.