## org.das2.util.filesystem.FileObject

Class for describing and accessing files in file systems. This is similar to java.io.File, except that it can describe files on remote file systems like an ftp site.

Note: this is modelled after the NetBeans fileSystem FileObject, with the thought that we might use it later.

## FileObject( )

## canRead

canRead( ) → boolean

returns true if the file can be read by the client.

### Returns:

true if the file can be read (see getInputStream)
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## exists

exists( ) → boolean

returns true if the file exists. This may have the side effect of downloading the file.

### Returns:

true if the file exists
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## getCapability

getCapability( java.lang.Class clazz ) → Object

returns extra capabilities, such as writing to the filesystem.

### Parameters

clazz - a java.lang.Class

### Returns:

an Object
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## getChannel

getChannel( ProgressMonitor monitor ) → java.nio.channels.ReadableByteChannel

opens a Channel, perhaps transferring the file to a local cache first. monitor is used to monitor the download.

### Parameters

monitor - for monitoring the download. The monitor won't be used when the access is immediate, for example with local FileObjects.

### Returns:

a java.nio.channels.Channel for fast IO reads.
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## getChannel

getChannel( ) → java.nio.channels.ReadableByteChannel

opens a Channel, but without a monitor. Note this may block at sub-interactive time if the FileObject needs to be downloaded before access.

### Returns:

a java.nio.channels.Channel for fast IO reads.
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## getChildren

getChildren( ) → org.das2.util.filesystem.FileObject[]

returns objects within a folder.

### Returns:

an array of all FileObjects with the folder.
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## getFile

getFile( ProgressMonitor monitor ) → java.io.File

gets a File object that can be opened by the client. This may download a remote file, so a progress monitor can be used to monitor the download.

### Parameters

monitor - for monitoring the download. The monitor won't be used when the access is immediate, for example with local FileObjects.

### Returns:

a reference to a File that can be opened.
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## getFile

getFile( ) → java.io.File

gets a File object that can be opened by the client. Note this may block at sub-interactive time if the remote file needs to be downloaded before access.

### Returns:

a reference to a File that can be opened.
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## getInputStream

getInputStream( ProgressMonitor monitor ) → java.io.InputStream

opens an inputStream, perhaps transferring the file to a cache first.

### Parameters

monitor - for monitoring the download. The monitor won't be used when the access is immediate, for example with local FileObjects.

### Returns:

an InputStream
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## getInputStream

getInputStream( ) → java.io.InputStream

opens an inputStream, perhaps transferring the file to a cache first. Note no monitor is used but this may block at sub-interactive time until the file is downloaded.

### Returns:

an InputStream
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## getNameExt

getNameExt( ) → String

returns the canonical name of the file within the filesystem. For example, in the local filesystem /mnt/data/steven/, /mnt/data/steven/jan/01.dat would be /jan/01.dat. For example, /a/b/c.dat.

### Returns:

the name of the file within the FileSystem.
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## getParent

getParent( ) → org.das2.util.filesystem.FileObject

returns the parent FileObject (a folder). If the fileObject is root, then null should be returned.

### Returns:

the parent folder of this object.
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## getSize

getSize( ) → long

returns the size of the file.

### Returns:

the size in bytes of the file, and -1 if the size is unknown.
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## isData

isData( ) → boolean

returns true if the file is a data file that to be used reading or writing data. (And not a folder.)

### Returns:

true if the file is a data file
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## isFolder

isFolder( ) → boolean

indicates the type of FileObject

### Returns:

true if the object is a folder (directory).
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## isLocal

isLocal( ) → boolean

returns true if the file is locally available, meaning clients can call getFile() and the readable File reference will be available in interactive time. Note that isLocal does not imply exists(). Also, This may result in side effects such as a website hit.

### Returns:

true if the file is locally available and fresh
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## isReadOnly

isReadOnly( ) → boolean

true is the file is read-only.

### Returns:

true if the file is read-only
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## isRoot

isRoot( ) → boolean

returns true if this is the root of the filesystem it came from.

### Returns:

true if this is the root of the filesystem it came from.
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## lastModified

lastModified( ) → java.util.Date

returns the Date when the file was last modified. or new Date(0L) if the date is not available.

### Returns:

the last modified Date, or new Date(0) if it is not available.
[search for examples] [view on GitHub] [view on old javadoc] [view source]

## removeLocalFile

removeLocalFile( ) → boolean

remove the local file in the cache, if any. This can/will be overriden by other filesystems.

### Returns:

true if the action was handled. (Local files are not deleted.)
[search for examples] [view on GitHub] [view on old javadoc] [view source]