public class IO
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
IO.HttpResult
Holds the result of an HTTP action.
|
Modifier and Type | Field and Description |
---|---|
static int |
default_file_buffersize |
static int |
default_socket_buffersize |
Constructor and Description |
---|
IO() |
Modifier and Type | Method and Description |
---|---|
static long |
appendToFile(java.io.InputStream in,
java.lang.String fileOutName) |
static long |
copy(java.io.InputStream in,
java.io.OutputStream out)
copy all bytes from in to out.
|
static void |
copy2File(byte[] src,
java.lang.String fileOut)
copy file to output stream
|
static long |
copy2null(java.nio.channels.FileChannel in,
int buffersize)
copy all bytes from in and throw them away.
|
static long |
copy2null(java.io.InputStream in,
int buffersize)
copy all bytes from in and throw them away.
|
static long |
copyB(java.io.InputStream in,
java.io.OutputStream out,
int bufferSize)
copy all bytes from in to out, specify buffer size
|
static void |
copyDirTree(java.lang.String fromDirName,
java.lang.String toDirName)
Copy an entire directory tree.
|
static void |
copyFile(java.io.File fileIn,
java.io.File fileOut)
copy one file to another.
|
static void |
copyFile(java.io.File fileIn,
java.io.OutputStream out)
copy file to output stream
|
static void |
copyFile(java.lang.String fileInName,
java.io.OutputStream out)
copy file to output stream
|
static void |
copyFile(java.lang.String fileInName,
java.lang.String fileOutName)
copy one file to another.
|
static void |
copyFileB(java.io.File fileIn,
java.io.OutputStream out,
int bufferSize)
copy file to output stream, specify internal buffer size
|
static void |
copyFileWithChannels(java.io.File fileIn,
java.nio.channels.WritableByteChannel out) |
static void |
copyMaxBytes(java.io.InputStream in,
java.io.OutputStream out,
int maxBytes)
Copy up to maxBytes bytes from in to out.
|
static long |
copyRafB(RandomAccessFile raf,
long offset,
long length,
java.io.OutputStream out)
Copy part of a RandomAccessFile to output stream
|
static long |
copyRafB(RandomAccessFile raf,
long offset,
long length,
java.io.OutputStream out,
byte[] buffer)
Copy part of a RandomAccessFile to output stream, specify internal buffer size
|
static long |
copyUrlB(java.lang.String urlString,
java.io.OutputStream out,
int bufferSize)
copy contents of URL to output stream, specify internal buffer size.
|
static java.io.InputStream |
getFileResource(java.lang.String resourcePath)
Open a resource as a Stream.
|
static java.io.InputStream |
getInputStreamFromUrl(java.lang.String urlString)
get input stream from URL
|
static IO.HttpResult |
putToURL(java.lang.String urlString,
java.lang.String contents)
use HTTP PUT to send the contents to the named URL.
|
static java.lang.String |
readContents(java.io.InputStream is)
Read the contents from the inputStream and place into a String,
with any error messages put in the return String.
|
static java.lang.String |
readContents(java.io.InputStream is,
java.lang.String charset)
Read the contents from the inputStream and place into a String,
with any error messages put in the return String.
|
static byte[] |
readContentsToByteArray(java.io.InputStream is)
Read the contents from the inputStream and place into a byte array,
with any error messages put in the return String.
|
static java.lang.String |
readFile(java.lang.String filename)
Read the contents from the named file and place into a String, assuming UTF-8 encoding.
|
static byte[] |
readFileToByteArray(java.lang.String filename)
Read the file and place contents into a byte array,
with any error messages put in the return String.
|
static java.lang.String |
readURLcontents(java.lang.String urlString)
Read the contents from the named URL and place into a String,
with any error messages put in the return String.
|
static byte[] |
readURLContentsToByteArray(java.lang.String urlString)
Read the contents from the given URL and place into a byte array,
with any error messages put in the return String.
|
static java.lang.String |
readURLcontentsWithException(java.lang.String urlString)
Read the contents from the named URL and place into a String.
|
static java.lang.String |
readURLtoFile(java.lang.String urlString,
java.io.File file)
read the contents from the named URL, write to a file.
|
static java.lang.String |
readURLtoFileWithExceptions(java.lang.String urlString,
java.io.File file)
read the contents from the named URL, write to a file.
|
static java.lang.String |
readURLtoFileWithExceptions(java.lang.String urlString,
java.io.File file,
int buffer_size)
read the contents from the named URL, write to a file.
|
static long |
touch(java.nio.channels.FileChannel in,
int buffersize) |
static long |
touch(java.io.InputStream in,
int buffersize) |
static void |
writeContents(java.lang.String contents,
java.io.OutputStream os)
Wite the contents from the String to a Stream,
|
static void |
writeToFile(byte[] contents,
java.io.File file)
Write byte[] contents to a file.
|
static long |
writeToFile(java.io.InputStream in,
java.lang.String fileOutName)
copy input stream to file.
|
static void |
writeToFile(java.lang.String contents,
java.io.File file)
Write String contents to a file, using UTF-8 encoding.
|
static void |
writeToFile(java.lang.String contents,
java.lang.String fileOutName)
Write contents to a file, using UTF-8 encoding.
|
public static final int default_file_buffersize
public static final int default_socket_buffersize
public static long appendToFile(java.io.InputStream in, java.lang.String fileOutName) throws java.io.IOException
java.io.IOException
public static long copy(java.io.InputStream in, java.io.OutputStream out) throws java.io.IOException
in
- InputStreamout
- OutputStreamjava.io.IOException
- on io errorpublic static void copy2File(byte[] src, java.lang.String fileOut) throws java.io.IOException
src
- sourcefileOut
- copy to this filejava.io.IOException
- on io errorpublic static long copy2null(java.nio.channels.FileChannel in, int buffersize) throws java.io.IOException
in
- FileChannelbuffersize
- size of buffer to use, if -1 uses default value (9200)java.io.IOException
- on io errorpublic static long copy2null(java.io.InputStream in, int buffersize) throws java.io.IOException
in
- InputStreambuffersize
- size of buffer to use, if -1 uses default value (9200)java.io.IOException
- on io errorpublic static long copyB(java.io.InputStream in, java.io.OutputStream out, int bufferSize) throws java.io.IOException
in
- InputStreamout
- OutputStreambufferSize
- : internal buffer size.java.io.IOException
- on io errorpublic static void copyDirTree(java.lang.String fromDirName, java.lang.String toDirName) throws java.io.IOException
fromDirName
- from this directory (do nothing if not exist)toDirName
- to this directory (will create if not exist)java.io.IOException
- on io errorpublic static void copyFile(java.io.File fileIn, java.io.File fileOut) throws java.io.IOException
fileIn
- copy from this file, which must exist.fileOut
- copy to this file, which is overrwritten if already exists.java.io.IOException
- on io errorpublic static void copyFile(java.io.File fileIn, java.io.OutputStream out) throws java.io.IOException
fileIn
- copy this fileout
- copy herejava.io.IOException
- on io errorpublic static void copyFile(java.lang.String fileInName, java.io.OutputStream out) throws java.io.IOException
fileInName
- open this fileout
- copy herejava.io.IOException
- on io errorpublic static void copyFile(java.lang.String fileInName, java.lang.String fileOutName) throws java.io.IOException
fileInName
- copy from this file, which must exist.fileOutName
- copy to this file, which is overrwritten if already exists.java.io.IOException
- on io errorpublic static void copyFileB(java.io.File fileIn, java.io.OutputStream out, int bufferSize) throws java.io.IOException
fileIn
- copy this fileout
- copy to this streambufferSize
- internal buffer size.java.io.IOException
- on io errorpublic static void copyFileWithChannels(java.io.File fileIn, java.nio.channels.WritableByteChannel out) throws java.io.IOException
java.io.IOException
public static void copyMaxBytes(java.io.InputStream in, java.io.OutputStream out, int maxBytes) throws java.io.IOException
in
- InputStreamout
- OutputStreammaxBytes
- number of bytes to copyjava.io.IOException
- on io errorpublic static long copyRafB(RandomAccessFile raf, long offset, long length, java.io.OutputStream out) throws java.io.IOException
raf
- copy this fileoffset
- start here (byte offset)length
- number of bytes to copyout
- copy to this streamjava.io.IOException
- on io errorpublic static long copyRafB(RandomAccessFile raf, long offset, long length, java.io.OutputStream out, byte[] buffer) throws java.io.IOException
raf
- copy this fileoffset
- start here (byte offset)length
- number of bytes to copyout
- copy to this streambuffer
- use this buffer.java.io.IOException
- on io errorpublic static long copyUrlB(java.lang.String urlString, java.io.OutputStream out, int bufferSize) throws java.io.IOException
urlString
- copy the contents of this URLout
- copy to this stream. If null, throw bytes awaybufferSize
- internal buffer size.java.io.IOException
- on io errorpublic static java.io.InputStream getFileResource(java.lang.String resourcePath)
resourcePath
- name of file path (use forward slashes!)public static java.io.InputStream getInputStreamFromUrl(java.lang.String urlString) throws java.io.IOException
urlString
- URLjava.io.IOException
- on io errorpublic static IO.HttpResult putToURL(java.lang.String urlString, java.lang.String contents)
urlString
- the URL to read from. must be http:contents
- String holding the contentspublic static java.lang.String readContents(java.io.InputStream is) throws java.io.IOException
is
- the inputStream to read from.java.io.IOException
- on io errorpublic static java.lang.String readContents(java.io.InputStream is, java.lang.String charset) throws java.io.IOException
is
- the inputStream to read from.java.io.IOException
- on io errorpublic static byte[] readContentsToByteArray(java.io.InputStream is) throws java.io.IOException
is
- the inputStream to read from.java.io.IOException
- on io errorpublic static java.lang.String readFile(java.lang.String filename) throws java.io.IOException
filename
- the URL to read from.java.io.IOException
- on io errorpublic static byte[] readFileToByteArray(java.lang.String filename) throws java.io.IOException
filename
- the file to read from.java.io.IOException
- on io errorpublic static java.lang.String readURLcontents(java.lang.String urlString)
urlString
- the URL to read from.public static byte[] readURLContentsToByteArray(java.lang.String urlString) throws java.io.IOException
urlString
- read from this URL.java.io.IOException
- on io errorpublic static java.lang.String readURLcontentsWithException(java.lang.String urlString) throws java.io.IOException
urlString
- the URL to read from.java.io.IOException
- if failspublic static java.lang.String readURLtoFile(java.lang.String urlString, java.io.File file)
urlString
- the URL to read from.file
- write to this filepublic static java.lang.String readURLtoFileWithExceptions(java.lang.String urlString, java.io.File file) throws java.io.IOException
urlString
- the URL to read from.file
- write to this filejava.io.IOException
- if failurepublic static java.lang.String readURLtoFileWithExceptions(java.lang.String urlString, java.io.File file, int buffer_size) throws java.io.IOException
urlString
- the URL to read from.file
- write to this filebuffer_size
- read/write in this size chunksjava.io.IOException
- if failurepublic static long touch(java.nio.channels.FileChannel in, int buffersize) throws java.io.IOException
java.io.IOException
public static long touch(java.io.InputStream in, int buffersize) throws java.io.IOException
java.io.IOException
public static void writeContents(java.lang.String contents, java.io.OutputStream os) throws java.io.IOException
contents
- String holding the contents.os
- write to this OutputStreamjava.io.IOException
- on io errorpublic static void writeToFile(byte[] contents, java.io.File file) throws java.io.IOException
contents
- String holding the contentsfile
- write to this file (overwrite if exists)java.io.IOException
- on io errorpublic static long writeToFile(java.io.InputStream in, java.lang.String fileOutName) throws java.io.IOException
in
- copy from herefileOutName
- open this file (overwrite) and copy to it.java.io.IOException
- on io errorpublic static void writeToFile(java.lang.String contents, java.io.File file) throws java.io.IOException
contents
- String holding the contentsfile
- write to this file (overwrite if exists)java.io.IOException
- on io errorpublic static void writeToFile(java.lang.String contents, java.lang.String fileOutName) throws java.io.IOException
contents
- String holding the contentsfileOutName
- write to this file (overwrite if exists)java.io.IOException
- on io error