gov.nasa.worldwind.util
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Field Summary | |
|---|---|
static String |
DELETE_ON_EXIT_PREFIX
|
static String |
ILLEGAL_FILE_PATH_PART_CHARACTERS
|
| Constructor Summary | |
|---|---|
WWIO()
|
|
| Method Summary | |
|---|---|
static String |
byteBufferToString(ByteBuffer buffer,
String encoding)
Create a String from a ByteBuffer. |
static void |
closeStream(Object stream,
String name)
Close a stream and catch any IOException generated in the process. |
static Proxy |
configureProxy()
|
static File |
convertURLToFile(URL url)
Converts a specified URL as to a path in the local file system. |
static void |
copyDirectory(File source,
File destination,
boolean copySubDirectories)
|
static void |
copyFile(File source,
File destination)
|
static void |
deflateBufferToFile(ByteBuffer buffer,
File file)
|
static void |
deleteDirectory(File file)
|
static String |
formPath(String... pathParts)
|
static String |
getFilename(String filePath)
Returns the name of the file or directory denoted by the specified path. |
static Object |
getFileOrResourceAsStream(String path,
Class c)
|
static InputStream |
getInputStreamFromByteBuffer(ByteBuffer buffer)
Creates an InputStream for the contents of a ByteBuffer. |
static InputStream |
getInputStreamFromString(String string)
Creates an InputStream for the contents of a String. |
static String |
getParentFilePath(String filePath)
Returns the file path's parent directory path, or null if the file path does not have a parent. |
static String |
getSuffix(String filePath)
|
static ByteBuffer |
inflateFileToBuffer(File file)
|
static ByteBuffer |
inflateStreamToBuffer(InputStream inputStream)
|
static boolean |
isAncestorOf(File file,
File ancestor)
|
static boolean |
isFileOutOfDate(URL url,
long expiryTime)
|
static String |
makeSuffixForMimeType(String mimeType)
|
static MappedByteBuffer |
mapFile(File file)
|
static InputStream |
openFileOrResourceStream(String fileName,
Class c)
Opens a file located via an absolute path or a path relative to the classpath. |
static ByteBuffer |
readFileToBuffer(File file)
|
static ByteBuffer |
readStreamToBuffer(InputStream inputStream)
|
static String |
readTextFile(File file)
Open and read a text file into String. |
static ByteBuffer |
readURLContentToBuffer(URL url)
|
static ByteBuffer |
readZipEntryToBuffer(File zipFile,
String entryName)
|
static String |
replaceSuffix(String in,
String newSuffix)
|
static boolean |
saveBuffer(ByteBuffer buffer,
File file)
|
static boolean |
saveBuffer(ByteBuffer buffer,
File file,
boolean forceFilesystemWrite)
|
static boolean |
saveBufferToStream(ByteBuffer buffer,
OutputStream fos)
|
static File |
saveBufferToTempFile(ByteBuffer buffer,
String suffix)
|
static ByteBuffer |
stringToByteBuffer(String string,
String encoding)
Create a ByteBuffer from a String. |
static String |
stripIllegalFileNameCharacters(String s)
|
static String |
stripLeadingSeparator(String s)
|
static String |
stripLeadingZeros(String s)
|
static String |
stripTrailingSeparator(String s)
|
static void |
writeTextFile(String text,
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 String DELETE_ON_EXIT_PREFIX
public static final String ILLEGAL_FILE_PATH_PART_CHARACTERS
| Constructor Detail |
|---|
public WWIO()
| Method Detail |
|---|
public static String byteBufferToString(ByteBuffer buffer, 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(Object stream, 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 Proxy configureProxy()
public static File convertURLToFile(URL url)
url - the URL to convert to a local file path.
IllegalArgumentException - if the url is null.public static void copyDirectory(File source, File destination, boolean copySubDirectories) throws IOException
IOExceptionpublic static void copyFile(File source, File destination) throws IOException
IOExceptionpublic static void deflateBufferToFile(ByteBuffer buffer, File file) throws IOException
IOExceptionpublic static void deleteDirectory(File file) throws IOException
IOExceptionpublic static String formPath(String... pathParts)
public static String getFilename(String filePath)
filePath - a file path String.
IllegalArgumentException - if the file path is null.public static Object getFileOrResourceAsStream(String path, Class c)
public static InputStream getInputStreamFromByteBuffer(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.
IllegalArgumentException - if buffer is null.public static InputStream getInputStreamFromString(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.
InputStream for the string's contents.
IllegalArgumentException - if string is null.public static String getParentFilePath(String filePath)
filePath - a file path String.
IllegalArgumentException - if the file path is null.public static String getSuffix(String filePath)
public static ByteBuffer inflateFileToBuffer(File file) throws IOException
IOExceptionpublic static ByteBuffer inflateStreamToBuffer(InputStream inputStream) throws IOException
IOExceptionpublic static boolean isAncestorOf(File file, File ancestor)
public static boolean isFileOutOfDate(URL url, long expiryTime)
public static String makeSuffixForMimeType(String mimeType)
public static MappedByteBuffer mapFile(File file) throws IOException
IOExceptionpublic static InputStream openFileOrResourceStream(String fileName, 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
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 ByteBuffer readFileToBuffer(File file) throws IOException
IOExceptionpublic static ByteBuffer readStreamToBuffer(InputStream inputStream) throws IOException
IOExceptionpublic static String readTextFile(File file)
String.
file - a File reference to the file to open and read.
String containing the contents of the file.
IllegalArgumentException - if the file is null.public static ByteBuffer readURLContentToBuffer(URL url) throws IOException
IOExceptionpublic static ByteBuffer readZipEntryToBuffer(File zipFile, String entryName) throws IOException
IOExceptionpublic static String replaceSuffix(String in, String newSuffix)
public static boolean saveBuffer(ByteBuffer buffer, File file) throws IOException
IOExceptionpublic static boolean saveBuffer(ByteBuffer buffer, File file, boolean forceFilesystemWrite) throws IOException
IOExceptionpublic static boolean saveBufferToStream(ByteBuffer buffer, OutputStream fos) throws IOException
IOExceptionpublic static File saveBufferToTempFile(ByteBuffer buffer, String suffix) throws IOException
IOExceptionpublic static ByteBuffer stringToByteBuffer(String string, String encoding) throws UnsupportedEncodingException
ByteBuffer from a String.
string - the string to convert.encoding - the encoding do use. If null is specified then UTF-8 is used.
UnsupportedEncodingException - if the specified encoding is not supportedpublic static String stripIllegalFileNameCharacters(String s)
public static String stripLeadingSeparator(String s)
public static String stripLeadingZeros(String s)
public static String stripTrailingSeparator(String s)
public static void writeTextFile(String text, File file)
String to a text file.
text - the String to write to the file.file - a File reference to the file to create.
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 | ||||||||