Package com.badlogic.gdx.files
Class FileHandleStream
- java.lang.Object
-
- com.badlogic.gdx.files.FileHandle
-
- com.badlogic.gdx.files.FileHandleStream
-
public abstract class FileHandleStream extends FileHandle
A FileHandle intended to be subclassed for the purpose of implementingread()and/orwrite(boolean). Methods that would manipulate the file instead throw UnsupportedOperationException.
-
-
Field Summary
-
Fields inherited from class com.badlogic.gdx.files.FileHandle
file, type
-
-
Constructor Summary
Constructors Constructor Description FileHandleStream(java.lang.String path)Create anFiles.FileType.Absolutefile at the given location.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FileHandlechild(java.lang.String name)Returns a handle to the child with the specified name.voidcopyTo(FileHandle dest)Copies this file or directory to the specified file or directory.booleandelete()Deletes this file or empty directory and returns success.booleandeleteDirectory()Deletes this file or directory and all children, recursively.voidemptyDirectory()Deletes all children of this directory, recursively.voidemptyDirectory(boolean preserveTree)Deletes all children of this directory, recursively.booleanexists()Returns true if the file exists.booleanisDirectory()Returns true if this file is a directory.longlength()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.voidmkdirs()voidmoveTo(FileHandle dest)Moves this file to the specified file, overwriting the file if it already exists.FileHandleparent()java.io.InputStreamread()Returns a stream for reading this file as bytes.FileHandlesibling(java.lang.String name)Returns a handle to the sibling with the specified name.java.io.OutputStreamwrite(boolean overwrite)Returns a stream for writing to this file.-
Methods inherited from class com.badlogic.gdx.files.FileHandle
equals, extension, file, hashCode, lastModified, list, list, list, map, map, name, nameWithoutExtension, path, pathWithoutExtension, read, readBytes, readBytes, reader, reader, reader, reader, readString, readString, tempDirectory, tempFile, toString, type, write, write, writeBytes, writeBytes, writer, writer, writeString, writeString
-
-
-
-
Constructor Detail
-
FileHandleStream
public FileHandleStream(java.lang.String path)
Create anFiles.FileType.Absolutefile at the given location.
-
-
Method Detail
-
isDirectory
public boolean isDirectory()
Description copied from class:FileHandleReturns true if this file is a directory. Always returns false for classpath files. On Android, anFiles.FileType.Internalhandle to an empty directory will return false. On the desktop, anFiles.FileType.Internalhandle to a directory on the classpath will return false.- Overrides:
isDirectoryin classFileHandle
-
length
public long length()
Description copied from class:FileHandleReturns 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:
lengthin classFileHandle
-
exists
public boolean exists()
Description copied from class:FileHandleReturns true if the file exists. On Android, aFiles.FileType.ClasspathorFiles.FileType.Internalhandle to a directory will always return false. Note that this can be very slow for internal files on Android!- Overrides:
existsin classFileHandle
-
child
public FileHandle child(java.lang.String name)
Description copied from class:FileHandleReturns a handle to the child with the specified name.- Overrides:
childin classFileHandle
-
sibling
public FileHandle sibling(java.lang.String name)
Description copied from class:FileHandleReturns a handle to the sibling with the specified name.- Overrides:
siblingin classFileHandle
-
parent
public FileHandle parent()
- Overrides:
parentin classFileHandle
-
read
public java.io.InputStream read()
Description copied from class:FileHandleReturns a stream for reading this file as bytes.- Overrides:
readin classFileHandle
-
write
public java.io.OutputStream write(boolean overwrite)
Description copied from class:FileHandleReturns a stream for writing to this file. Parent directories will be created if necessary.- Overrides:
writein classFileHandle- 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:FileHandleReturns 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, anFiles.FileType.Internalhandle to a directory on the classpath will return a zero length array.- Overrides:
listin classFileHandle
-
mkdirs
public void mkdirs()
- Overrides:
mkdirsin classFileHandle
-
delete
public boolean delete()
Description copied from class:FileHandleDeletes this file or empty directory and returns success. Will not delete a directory that has children.- Overrides:
deletein classFileHandle
-
deleteDirectory
public boolean deleteDirectory()
Description copied from class:FileHandleDeletes this file or directory and all children, recursively.- Overrides:
deleteDirectoryin classFileHandle
-
copyTo
public void copyTo(FileHandle dest)
Description copied from class:FileHandleCopies 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:
copyToin classFileHandle
-
moveTo
public void moveTo(FileHandle dest)
Description copied from class:FileHandleMoves this file to the specified file, overwriting the file if it already exists.- Overrides:
moveToin classFileHandle
-
emptyDirectory
public void emptyDirectory()
Description copied from class:FileHandleDeletes all children of this directory, recursively.- Overrides:
emptyDirectoryin classFileHandle
-
emptyDirectory
public void emptyDirectory(boolean preserveTree)
Description copied from class:FileHandleDeletes all children of this directory, recursively. Optionally preserving the folder structure.- Overrides:
emptyDirectoryin classFileHandle
-
-