com.badlogic.gdx.files
Class FileHandleStream

java.lang.Object
  extended by com.badlogic.gdx.files.FileHandle
      extended by com.badlogic.gdx.files.FileHandleStream

public abstract class FileHandleStream
extends FileHandle

A FileHandle intended to be subclassed for the purpose of implementing read() and/or write(boolean). Methods that would manipulate the file instead throw UnsupportedOperationException.

Author:
Nathan Sweet

Constructor Summary
FileHandleStream(String path)
          Create an Files.FileType.Absolute file at the given location.
 
Method Summary
 FileHandle child(String name)
          Returns a handle to the child with the specified name.
 void copyTo(FileHandle dest)
          Copies this file or directory to the specified file or directory.
 boolean delete()
          Deletes this file or empty directory and returns success.
 boolean deleteDirectory()
          Deletes this file or directory and all children, recursively.
 boolean exists()
          Returns true if the file exists.
 boolean isDirectory()
          Returns true if this file is a directory.
 long length()
          Returns the length in bytes of this file, or 0 if this file is a directory, does not exist, or the size cannot otherwise be determined.
 FileHandle[] list()
          Returns the paths to the children of this directory.
 void mkdirs()
           
 void moveTo(FileHandle dest)
          Moves this file to the specified file, overwriting the file if it already exists.
 FileHandle parent()
           
 InputStream read()
          Returns a stream for reading this file as bytes.
 FileHandle sibling(String name)
          Returns a handle to the sibling with the specified name.
 OutputStream write(boolean overwrite)
          Returns a stream for writing to this file.
 
Methods inherited from class com.badlogic.gdx.files.FileHandle
emptyDirectory, emptyDirectory, equals, extension, file, hashCode, lastModified, list, name, nameWithoutExtension, path, pathWithoutExtension, read, readBytes, readBytes, reader, reader, reader, reader, readString, readString, tempDirectory, tempFile, toString, type, write, writeBytes, writeBytes, writer, writer, writeString, writeString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FileHandleStream

public FileHandleStream(String path)
Create an Files.FileType.Absolute file at the given location.

Method Detail

isDirectory

public boolean isDirectory()
Description copied from class: FileHandle
Returns true if this file is a directory. Always returns false for classpath files. On Android, an Files.FileType.Internal handle to an empty directory will return false. On the desktop, an Files.FileType.Internal handle to a directory on the classpath will return false.

Overrides:
isDirectory in class FileHandle

length

public long length()
Description copied from class: FileHandle
Returns the length in bytes of this file, or 0 if this file is a directory, does not exist, or the size cannot otherwise be determined.

Overrides:
length in class FileHandle

exists

public boolean exists()
Description copied from class: FileHandle
Returns true if the file exists. On Android, a Files.FileType.Classpath or Files.FileType.Internal handle to a directory will always return false. Note that this can be very slow for internal files on Android!

Overrides:
exists in class FileHandle

child

public FileHandle child(String name)
Description copied from class: FileHandle
Returns a handle to the child with the specified name.

Overrides:
child in class FileHandle

sibling

public FileHandle sibling(String name)
Description copied from class: FileHandle
Returns a handle to the sibling with the specified name.

Overrides:
sibling in class FileHandle

parent

public FileHandle parent()
Overrides:
parent in class FileHandle

read

public InputStream read()
Description copied from class: FileHandle
Returns a stream for reading this file as bytes.

Overrides:
read in class FileHandle

write

public OutputStream write(boolean overwrite)
Description copied from class: FileHandle
Returns a stream for writing to this file. Parent directories will be created if necessary.

Overrides:
write in class FileHandle
Parameters:
overwrite - If false, this file will be overwritten if it exists, otherwise it will be appended.

list

public FileHandle[] list()
Description copied from class: FileHandle
Returns the paths to the children of this directory. Returns an empty list if this file handle represents a file and not a directory. On the desktop, an Files.FileType.Internal handle to a directory on the classpath will return a zero length array.

Overrides:
list in class FileHandle

mkdirs

public void mkdirs()
Overrides:
mkdirs in class FileHandle

delete

public boolean delete()
Description copied from class: FileHandle
Deletes this file or empty directory and returns success. Will not delete a directory that has children.

Overrides:
delete in class FileHandle

deleteDirectory

public boolean deleteDirectory()
Description copied from class: FileHandle
Deletes this file or directory and all children, recursively.

Overrides:
deleteDirectory in class FileHandle

copyTo

public void copyTo(FileHandle dest)
Description copied from class: FileHandle
Copies this file or directory to the specified file or directory. If this handle is a file, then 1) if the destination is a file, it is overwritten, or 2) if the destination is a directory, this file is copied into it, or 3) if the destination doesn't exist, FileHandle.mkdirs() is called on the destination's parent and this file is copied into it with a new name. If this handle is a directory, then 1) if the destination is a file, GdxRuntimeException is thrown, or 2) if the destination is a directory, this directory is copied into it recursively, overwriting existing files, or 3) if the destination doesn't exist, FileHandle.mkdirs() is called on the destination and this directory is copied into it recursively.

Overrides:
copyTo in class FileHandle

moveTo

public void moveTo(FileHandle dest)
Description copied from class: FileHandle
Moves this file to the specified file, overwriting the file if it already exists.

Overrides:
moveTo in class FileHandle


Copyright © 2013. All Rights Reserved.