|
NASA World Wind | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectgov.nasa.worldwind.util.WWIO
public class WWIO
| Field Summary | |
|---|---|
static java.lang.String |
DELETE_ON_EXIT_PREFIX
|
static java.lang.String |
ILLEGAL_FILE_PATH_PART_CHARACTERS
|
| Constructor Summary | |
|---|---|
WWIO()
|
|
| Method Summary | |
|---|---|
static java.lang.String |
byteBufferToString(java.nio.ByteBuffer buffer,
java.lang.String encoding)
Create a String from a ByteBuffer. |
static void |
closeStream(java.lang.Object stream,
java.lang.String name)
Close a stream and catch any IOException generated in the process. |
static java.net.Proxy |
configureProxy()
|
static java.io.File |
convertURLToFile(java.net.URL url)
Converts a specified URL as to a path in the local file system. |
static void |
copyDirectory(java.io.File source,
java.io.File destination,
boolean copySubDirectories)
|
static void |
copyFile(java.io.File source,
java.io.File destination)
|
static void |
deflateBufferToFile(java.nio.ByteBuffer buffer,
java.io.File file)
|
static void |
deleteDirectory(java.io.File file)
|
static java.lang.String |
formPath(java.lang.String... pathParts)
|
static java.lang.String |
getFilename(java.lang.String filePath)
Returns the name of the file or directory denoted by the specified path. |
static java.lang.Object |
getFileOrResourceAsStream(java.lang.String path,
java.lang.Class c)
|
static java.io.InputStream |
getInputStreamFromByteBuffer(java.nio.ByteBuffer buffer)
Creates an InputStream for the contents of a ByteBuffer. |
static java.io.InputStream |
getInputStreamFromString(java.lang.String string)
Creates an InputStream for the contents of a String. |
static java.io.InputStream |
getInputStreamFromString(java.lang.String string,
java.lang.String encoding)
Creates an InputStream for the contents of a String. |
static java.lang.String |
getParentFilePath(java.lang.String filePath)
Returns the file path's parent directory path, or null if the file path does not have a parent. |
static java.lang.String |
getSuffix(java.lang.String filePath)
|
static java.nio.ByteBuffer |
inflateFileToBuffer(java.io.File file)
|
static java.nio.ByteBuffer |
inflateStreamToBuffer(java.io.InputStream inputStream)
|
static boolean |
isAncestorOf(java.io.File file,
java.io.File ancestor)
|
static boolean |
isFileOutOfDate(java.net.URL url,
long expiryTime)
|
static java.lang.String |
makeSuffixForMimeType(java.lang.String mimeType)
|
static java.net.URL |
makeURL(java.lang.String path)
|
static java.nio.MappedByteBuffer |
mapFile(java.io.File file)
|
static java.io.InputStream |
openFileOrResourceStream(java.lang.String fileName,
java.lang.Class c)
Opens a file located via an absolute path or a path relative to the classpath. |
static java.io.Reader |
openReader(java.lang.Object src)
Open a reader on an input source. |
static java.nio.ByteBuffer |
readFileToBuffer(java.io.File file)
Reads all the bytes from the specified File, returning the bytes as a non-direct ByteBuffer with
the current JVM byte order. |
static java.nio.ByteBuffer |
readFileToBuffer(java.io.File file,
boolean allocateDirect)
Reads all the bytes from the specified File, returning the bytes as a ByteBuffer with the current
JVM byte order. |
static java.nio.ByteBuffer |
readStreamToBuffer(java.io.InputStream inputStream)
Reads all the available bytes from the specified InputStream, returning the bytes as a non-direct ByteBuffer with the current JVM byte order. |
static java.nio.ByteBuffer |
readStreamToBuffer(java.io.InputStream inputStream,
boolean allocateDirect)
Reads all the available bytes from the specified InputStream, returning the bytes as a ByteBuffer
with the current JVM byte order. |
static java.lang.String |
readTextFile(java.io.File file)
Open and read a text file into String. |
static java.nio.ByteBuffer |
readURLContentToBuffer(java.net.URL url)
Reads all the bytes from the specified URL, returning the bytes as a non-direct ByteBuffer with
the current JVM byte order. |
static java.nio.ByteBuffer |
readURLContentToBuffer(java.net.URL url,
boolean allocateDirect)
Reads all the bytes from the specified URL, returning the bytes as a ByteBuffer with the current
JVM byte order. |
static java.nio.ByteBuffer |
readZipEntryToBuffer(java.io.File zipFile,
java.lang.String entryName)
|
static java.lang.String |
replaceSuffix(java.lang.String in,
java.lang.String newSuffix)
|
static boolean |
saveBuffer(java.nio.ByteBuffer buffer,
java.io.File file)
|
static boolean |
saveBuffer(java.nio.ByteBuffer buffer,
java.io.File file,
boolean forceFilesystemWrite)
|
static boolean |
saveBufferToStream(java.nio.ByteBuffer buffer,
java.io.OutputStream fos)
|
static java.io.File |
saveBufferToTempFile(java.nio.ByteBuffer buffer,
java.lang.String suffix)
|
static java.nio.ByteBuffer |
stringToByteBuffer(java.lang.String string,
java.lang.String encoding)
Create a ByteBuffer from a String. |
static java.lang.String |
stripIllegalFileNameCharacters(java.lang.String s)
|
static java.lang.String |
stripLeadingSeparator(java.lang.String s)
|
static java.lang.String |
stripLeadingZeros(java.lang.String s)
|
static java.lang.String |
stripTrailingSeparator(java.lang.String s)
|
static void |
writeTextFile(java.lang.String text,
java.io.File file)
Save a String to a text file. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String DELETE_ON_EXIT_PREFIX
public static final java.lang.String ILLEGAL_FILE_PATH_PART_CHARACTERS
| Constructor Detail |
|---|
public WWIO()
| Method Detail |
|---|
public static java.lang.String byteBufferToString(java.nio.ByteBuffer buffer,
java.lang.String encoding)
String from a ByteBuffer.
buffer - the byte buffer to convert.encoding - the encoding do use. If null is specified then UTF-8 is used.
public static void closeStream(java.lang.Object stream,
java.lang.String name)
IOException generated in the process. Stream types supported are InputStream, OutputStream, Reader and Writer.
stream - the stream to close. If null, this method does nothing.name - the name of the stream to place in the log message if an exception is encountered.public static java.net.Proxy configureProxy()
public static java.io.File convertURLToFile(java.net.URL url)
url - the URL to convert to a local file path.
java.lang.IllegalArgumentException - if the url is null.
public static void copyDirectory(java.io.File source,
java.io.File destination,
boolean copySubDirectories)
throws java.io.IOException
java.io.IOException
public static void copyFile(java.io.File source,
java.io.File destination)
throws java.io.IOException
java.io.IOException
public static void deflateBufferToFile(java.nio.ByteBuffer buffer,
java.io.File file)
throws java.io.IOException
java.io.IOException
public static void deleteDirectory(java.io.File file)
throws java.io.IOException
java.io.IOExceptionpublic static java.lang.String formPath(java.lang.String... pathParts)
public static java.lang.String getFilename(java.lang.String filePath)
filePath - a file path String.
java.lang.IllegalArgumentException - if the file path is null.
public static java.lang.Object getFileOrResourceAsStream(java.lang.String path,
java.lang.Class c)
public static java.io.InputStream getInputStreamFromByteBuffer(java.nio.ByteBuffer buffer)
InputStream for the contents of a ByteBuffer. The method creates a copy of the
buffer's contents and passes a steam reference to that copy.
buffer - the buffer to create a stream for.
InputStream for the buffer's contents.
java.lang.IllegalArgumentException - if buffer is null.public static java.io.InputStream getInputStreamFromString(java.lang.String string)
InputStream for the contents of a String. The method creates a copy of the string's
contents and passes a steam reference to that copy.
string - the string to create a stream for, encoded in UTF-8.
InputStream for the string's contents.
java.lang.IllegalArgumentException - if string is null.
public static java.io.InputStream getInputStreamFromString(java.lang.String string,
java.lang.String encoding)
InputStream for the contents of a String. The method creates a copy of the string's
contents and passes a steam reference to that copy.
string - the string to create a stream for.encoding - the character encoding of the string. UTF-8 is used if null.
InputStream for the string's contents.
java.lang.IllegalArgumentException - if string is null.public static java.lang.String getParentFilePath(java.lang.String filePath)
filePath - a file path String.
java.lang.IllegalArgumentException - if the file path is null.public static java.lang.String getSuffix(java.lang.String filePath)
public static java.nio.ByteBuffer inflateFileToBuffer(java.io.File file)
throws java.io.IOException
java.io.IOException
public static java.nio.ByteBuffer inflateStreamToBuffer(java.io.InputStream inputStream)
throws java.io.IOException
java.io.IOException
public static boolean isAncestorOf(java.io.File file,
java.io.File ancestor)
public static boolean isFileOutOfDate(java.net.URL url,
long expiryTime)
public static java.lang.String makeSuffixForMimeType(java.lang.String mimeType)
public static java.net.URL makeURL(java.lang.String path)
public static java.nio.MappedByteBuffer mapFile(java.io.File file)
throws java.io.IOException
java.io.IOException
public static java.io.InputStream openFileOrResourceStream(java.lang.String fileName,
java.lang.Class c)
fileName - the path of the file to open, either absolute or relative to the classpath.c - the class that will be used to find a path relative to the classpath.
InputStream to the open file
java.lang.IllegalArgumentException - if the file name is null.
WWRuntimeException - if an exception occurs or the file can't be found. The causing exception is
available via this exception's Throwable.initCause(Throwable) method.
public static java.io.Reader openReader(java.lang.Object src)
throws java.io.IOException
ReaderInputStreamFileURLString
src - the input source of one of the above types.
java.io.IOException - if i/o or other errors occur trying to create the reader.
public static java.nio.ByteBuffer readFileToBuffer(java.io.File file)
throws java.io.IOException
File, returning the bytes as a non-direct ByteBuffer with
the current JVM byte order. Non-direct buffers are backed by JVM heap memory.
file - the file to read.
java.lang.IllegalArgumentException - if the file is null.
java.io.IOException - if an I/O error occurs.
public static java.nio.ByteBuffer readFileToBuffer(java.io.File file,
boolean allocateDirect)
throws java.io.IOException
File, returning the bytes as a ByteBuffer with the current
JVM byte order. This returns a direct ByteBuffer if allocateDirect is true, and returns a non-direct ByteBuffer
otherwise. Direct buffers are backed by native memory, and may reside outside of the normal garbage-collected
heap. Non-direct buffers are backed by JVM heap memory.
file - the file to read.allocateDirect - true to allocate and return a direct buffer, false to allocate and return a non-direct
buffer.
java.lang.IllegalArgumentException - if the file is null.
java.io.IOException - if an I/O error occurs.
public static java.nio.ByteBuffer readStreamToBuffer(java.io.InputStream inputStream)
throws java.io.IOException
InputStream, returning the bytes as a non-direct ByteBuffer with the current JVM byte order. Non-direct buffers are backed by JVM heap memory.
inputStream - the stream to read.
java.lang.IllegalArgumentException - if the stream is null.
java.io.IOException - if an I/O error occurs.
public static java.nio.ByteBuffer readStreamToBuffer(java.io.InputStream inputStream,
boolean allocateDirect)
throws java.io.IOException
InputStream, returning the bytes as a ByteBuffer
with the current JVM byte order. This returns a direct ByteBuffer if allocateDirect is true, and returns a
non-direct ByteBuffer otherwise. Direct buffers are backed by native memory, and may reside outside of the normal
garbage-collected heap. Non-direct buffers are backed by JVM heap memory.
inputStream - the stream to read.allocateDirect - true to allocate and return a direct buffer, false to allocate and return a non-direct
buffer.
java.lang.IllegalArgumentException - if the stream is null.
java.io.IOException - if an I/O error occurs.public static java.lang.String readTextFile(java.io.File file)
String.
file - a File reference to the file to open and read.
String containing the contents of the file.
java.lang.IllegalArgumentException - if the file is null.
public static java.nio.ByteBuffer readURLContentToBuffer(java.net.URL url)
throws java.io.IOException
URL, returning the bytes as a non-direct ByteBuffer with
the current JVM byte order. Non-direct buffers are backed by JVM heap memory.
url - the URL to read.
java.lang.IllegalArgumentException - if the URL is null.
java.io.IOException - if an I/O error occurs.
public static java.nio.ByteBuffer readURLContentToBuffer(java.net.URL url,
boolean allocateDirect)
throws java.io.IOException
URL, returning the bytes as a ByteBuffer with the current
JVM byte order. This returns a direct ByteBuffer if allocateDirect is true, and returns a non-direct ByteBuffer
otherwise. Direct buffers are backed by native memory, and may resite outside of the normal garbage-collected
heap. Non-direct buffers are backed by JVM heap memory.
url - the URL to read.allocateDirect - true to allocate and return a direct buffer, false to allocate and return a non-direct
buffer.
java.lang.IllegalArgumentException - if the URL is null.
java.io.IOException - if an I/O error occurs.
public static java.nio.ByteBuffer readZipEntryToBuffer(java.io.File zipFile,
java.lang.String entryName)
throws java.io.IOException
java.io.IOException
public static java.lang.String replaceSuffix(java.lang.String in,
java.lang.String newSuffix)
public static boolean saveBuffer(java.nio.ByteBuffer buffer,
java.io.File file)
throws java.io.IOException
java.io.IOException
public static boolean saveBuffer(java.nio.ByteBuffer buffer,
java.io.File file,
boolean forceFilesystemWrite)
throws java.io.IOException
java.io.IOException
public static boolean saveBufferToStream(java.nio.ByteBuffer buffer,
java.io.OutputStream fos)
throws java.io.IOException
java.io.IOException
public static java.io.File saveBufferToTempFile(java.nio.ByteBuffer buffer,
java.lang.String suffix)
throws java.io.IOException
java.io.IOException
public static java.nio.ByteBuffer stringToByteBuffer(java.lang.String string,
java.lang.String encoding)
throws java.io.UnsupportedEncodingException
ByteBuffer from a String.
string - the string to convert.encoding - the encoding do use. If null is specified then UTF-8 is used.
java.io.UnsupportedEncodingException - if the specified encoding is not supportedpublic static java.lang.String stripIllegalFileNameCharacters(java.lang.String s)
public static java.lang.String stripLeadingSeparator(java.lang.String s)
public static java.lang.String stripLeadingZeros(java.lang.String s)
public static java.lang.String stripTrailingSeparator(java.lang.String s)
public static void writeTextFile(java.lang.String text,
java.io.File file)
String to a text file.
text - the String to write to the file.file - a File reference to the file to create.
java.lang.IllegalArgumentException - if the text string or file is null.
|
NASA World Wind | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||