Package thredds.filesystem
Class MFileOS
- java.lang.Object
-
- thredds.filesystem.MFileOS
-
- All Implemented Interfaces:
Comparable<MFile>,MFile
@ThreadSafe public class MFileOS extends Object implements MFile
Implements thredds.inventory.MFile using regular OS files.- Since:
- Jun 30, 2009
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompareTo(MFile o)booleanexists()Check if the MFile existsObjectgetAuxInfo()static MFileOSgetExistingFile(String filename)Make MFileOS if file exists, otherwise return nullFilegetFile()FileInputStreamgetInputStream()Get the MFile InputStreamlonggetLastModified()Get time of last modification at the time the MFile object was createdlonggetLength()Size of file in bytesStringgetName()The name is the farthest element from the root in the directory hierarchy.MFilegetParent()Get the parent of thisStringgetPath()Get full path name, replace \\ with /booleanisDirectory()booleanisReadable()voidsetAuxInfo(Object auxInfo)StringtoString()voidwriteToStream(OutputStream outputStream)Write the MFile to an OutputStreamvoidwriteToStream(OutputStream outputStream, long offset, long maxBytes)Write the MFile to an OutputStream
-
-
-
Method Detail
-
getExistingFile
@Nullable public static MFileOS getExistingFile(String filename)
Make MFileOS if file exists, otherwise return null- Parameters:
filename- name of the existing file.- Returns:
- MFileOS or null
-
getLastModified
public long getLastModified()
Description copied from interface:MFileGet time of last modification at the time the MFile object was created- Specified by:
getLastModifiedin interfaceMFile- Returns:
- time of last modification in Unix time (msecs since reference), or -1 if unknown
-
getLength
public long getLength()
Description copied from interface:MFileSize of file in bytes
-
isDirectory
public boolean isDirectory()
- Specified by:
isDirectoryin interfaceMFile
-
isReadable
public boolean isReadable()
- Specified by:
isReadablein interfaceMFile
-
getPath
public String getPath()
Description copied from interface:MFileGet full path name, replace \\ with /
-
getName
public String getName()
Description copied from interface:MFileThe name is the farthest element from the root in the directory hierarchy.
-
compareTo
public int compareTo(MFile o)
- Specified by:
compareToin interfaceComparable<MFile>- Specified by:
compareToin interfaceMFile
-
getAuxInfo
public Object getAuxInfo()
- Specified by:
getAuxInfoin interfaceMFile
-
setAuxInfo
public void setAuxInfo(Object auxInfo)
- Specified by:
setAuxInfoin interfaceMFile
-
exists
public boolean exists()
Description copied from interface:MFileCheck if the MFile exists
-
getInputStream
public FileInputStream getInputStream() throws FileNotFoundException
Description copied from interface:MFileGet the MFile InputStream- Specified by:
getInputStreamin interfaceMFile- Returns:
- the MFile InputStream
- Throws:
FileNotFoundException
-
writeToStream
public void writeToStream(OutputStream outputStream) throws IOException
Description copied from interface:MFileWrite the MFile to an OutputStream- Specified by:
writeToStreamin interfaceMFile- Parameters:
outputStream- the OutputStream the MFile contents should be written to- Throws:
IOException
-
writeToStream
public void writeToStream(OutputStream outputStream, long offset, long maxBytes) throws IOException
Description copied from interface:MFileWrite the MFile to an OutputStream- Specified by:
writeToStreamin interfaceMFile- Parameters:
outputStream- the OutputStream the MFile contents should be written tooffset- the index of the first byte to write outmaxBytes- the maximum number of bytes to copy- Throws:
IOException
-
getFile
public File getFile()
-
-