|
ProgramixGenericLib v5.0.1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.programix.io.IOTools
public class IOTools
Handy tools for working with I/O.
| Nested Class Summary | |
|---|---|
static class |
IOTools.BaseDirectoryResourceLocator
An implementation of IOTools.ResourceLocator that uses the specified
base directory to try to locate resources. |
static class |
IOTools.ClassLoaderResourceLocator
An implementation of IOTools.ResourceLocator that uses the specified
Class to try to locate resources. |
static class |
IOTools.ObjectStreamPair
An immutable holder of an ObjectInputStream and ObjectOutputStream pair. |
static interface |
IOTools.ResourceLocator
A ResourceLocator is used to assist in finding and opening InputStream's and URL's for an application based on the resources name. |
static class |
IOTools.ServletResourceLocator
An implementation of IOTools.ResourceLocator that uses the specified
HttpServlet to try to locate resources. |
| Field Summary | |
|---|---|
static int |
DEFAULT_BUFFER_SIZE
The default buffer size that is used with streams in the tools class. |
static int |
EOS
Constant for "end of stream" or more loosely "end of file". |
| Method Summary | |
|---|---|
static void |
closeQuietly(InputStream in)
Closes the specified stream and suppresses any IOException's that may be thrown. |
static void |
closeQuietly(InputStream in,
OutputStream out)
Closes the OutputStream and the InputStream [in that order]. |
static void |
closeQuietly(OutputStream out)
Closes the specified stream and suppresses any IOException's that may be thrown. |
static void |
closeQuietly(Reader in)
Closes the specified stream and suppresses any IOException's that may be thrown. |
static void |
closeQuietly(ServerSocket ss)
Closes the specified ServerSocket and suppresses any IOException's that may be thrown. |
static void |
closeQuietly(Socket socket)
Closes the specified Socket and suppresses any IOException's that may be thrown. |
static void |
closeQuietly(Socket socket,
InputStream in,
OutputStream out)
Closes the OutputStream, InputStream, and Socket [in that order]. |
static void |
closeQuietly(Socket socket,
Reader in,
Writer out)
Closes the Writer, Reader, and Socket [in that order]. |
static void |
closeQuietly(Writer out)
Closes the specified stream and suppresses any IOException's that may be thrown. |
static int |
copy(File source,
File destination)
Copies bytes between the files with the DEFAULT_BUFFER_SIZE and
closes both streams after the copy is complete. |
static int |
copy(InputStream in,
boolean closeInputStream,
OutputStream out,
boolean closeOutputStream)
Copies bytes between the streams with the DEFAULT_BUFFER_SIZE. |
static int |
copy(InputStream in,
boolean closeInputStream,
OutputStream out,
boolean closeOutputStream,
int transferBufferSize)
Copies all the bytes from the InputStream to the OutputStream. |
static int |
copy(InputStream in,
OutputStream out)
Copies bytes between the streams with the DEFAULT_BUFFER_SIZE
and closes both streams after the copy is complete. |
static BufferedReader |
createBufferedReader(File source)
Creates a BufferedReader using the default InputStreamReader. |
static BufferedReader |
createBufferedReader(InputStream rawIn)
Creates a BufferedReader using the default InputStreamReader constructor. |
static BufferedReader |
createBufferedReader(Socket socket)
Creates a BufferedReader using the default InputStreamReader. |
static BufferedReader |
createBufferedReader(URL source)
Creates a BufferedReader using the default InputStreamReader. |
static BufferedReader |
createBufferedReaderFromFile(String filename)
Creates a BufferedReader using the default InputStreamReader. |
static BufferedReader |
createBufferedReaderFromResource(String resourceLocation)
Creates a BufferedReader using the default InputStreamReader. |
static BufferedReader |
createBufferedReaderFromResource(String resourceLocation,
Class<?> searchStartPoint)
Creates a BufferedReader using the default InputStreamReader. |
static BufferedWriter |
createBufferedWriter(File destination)
Creates a BufferedWriter using the default OutputStreamWriter. |
static BufferedWriter |
createBufferedWriter(OutputStream rawOut)
Creates a BufferedWriter using the default OutputStreamWriter constructor. |
static BufferedWriter |
createBufferedWriter(Socket socket)
Creates a BufferedWriter using the default OutputStreamWriter. |
static BufferedWriter |
createBufferedWriterToFile(String filename)
Creates a BufferedWriter using the default OutputStreamWriter. |
static DataInputStream |
createDataInputStream(File source)
Creates a DataInputStream with buffering. |
static DataInputStream |
createDataInputStream(InputStream rawIn)
Creates a DataInputStream and adds buffering by wrapping a BufferedInputStream around the supplied InputStream, rawIn. |
static DataInputStream |
createDataInputStream(Socket socket)
Creates a DataInputStream with buffering. |
static DataInputStream |
createDataInputStream(URL source)
Creates a DataInputStream with buffering. |
static DataInputStream |
createDataInputStreamFromFile(String filename)
Creates a DataInputStream with buffering. |
static DataInputStream |
createDataInputStreamFromResource(String resourceLocation)
Creates a buffered DataInputStream. |
static DataInputStream |
createDataInputStreamFromResource(String resourceLocation,
Class<?> searchStartPoint)
Creates a buffered DataInputStream. |
static DataOutputStream |
createDataOutputStream(File destination)
Creates a DataOutputStream with buffering. |
static DataOutputStream |
createDataOutputStream(OutputStream rawOut)
Creates a DataOutputStream and adds buffering by wrapping a BufferedOutputStream around the supplied OutputStream, rawOut. |
static DataOutputStream |
createDataOutputStream(Socket socket)
Creates a DataOutputStream with buffering. |
static DataOutputStream |
createDataOutputStreamToFile(String filename)
Creates a DataOutputStream with buffering. |
static ObjectInputStream |
createObjectInputStream(File source)
Creates an ObjectInputStream with buffering. |
static ObjectInputStream |
createObjectInputStream(InputStream rawIn)
Creates an ObjectInputStream and adds buffering by wrapping a BufferedInputStream around the supplied InputStream, rawIn. |
static ObjectInputStream |
createObjectInputStream(Socket socket)
Creates an ObjectInputStream with buffering. |
static ObjectInputStream |
createObjectInputStream(URL source)
Creates an ObjectInputStream with buffering. |
static ObjectInputStream |
createObjectInputStreamFromFile(String filename)
Creates an ObjectInputStream with buffering. |
static ObjectInputStream |
createObjectInputStreamFromResource(String resourceLocation)
Creates a buffered ObjectInputStream. |
static ObjectInputStream |
createObjectInputStreamFromResource(String resourceLocation,
Class<?> searchStartPoint)
Creates a buffered ObjectInputStream. |
static ObjectOutputStream |
createObjectOutputStream(File destination)
Creates an ObjectOutputStream with buffering. |
static ObjectOutputStream |
createObjectOutputStream(OutputStream rawOut)
Creates an ObjectOutputStream and adds buffering by wrapping a BufferedOutputStream around the supplied OutputStream, rawOut. |
static ObjectOutputStream |
createObjectOutputStream(Socket socket)
Creates an ObjectOutputStream with buffering. |
static ObjectOutputStream |
createObjectOutputStreamToFile(String filename)
Creates an ObjectOutputStream with buffering. |
static IOTools.ObjectStreamPair |
createObjectStreamsAsync(InputStream rawIn,
OutputStream rawOut)
Creates an ObjectInputStream and an ObjectOutputStream with buffering on the specified InputStream and OutputStream. |
static IOTools.ObjectStreamPair |
createObjectStreamsAsync(Socket socket)
Creates an ObjectInputStream and an ObjectOutputStream with buffering on the specified InputStream and OutputStream. |
static IOTools.ObjectStreamPair |
createObjectStreamsForClient(InputStream rawIn,
OutputStream rawOut)
Creates an ObjectInputStream and an ObjectOutputStream with buffering on the specified InputStream and OutputStream. |
static IOTools.ObjectStreamPair |
createObjectStreamsForClient(Socket socket)
Creates an ObjectInputStream and an ObjectOutputStream with buffering on the specified InputStream and OutputStream. |
static IOTools.ObjectStreamPair |
createObjectStreamsForServer(InputStream rawIn,
OutputStream rawOut)
Creates an ObjectInputStream and an ObjectOutputStream with buffering on the specified InputStream and OutputStream. |
static IOTools.ObjectStreamPair |
createObjectStreamsForServer(Socket socket)
Creates an ObjectInputStream and an ObjectOutputStream with buffering on the specified Socket's streams. |
static InputStream |
getInputStreamForResource(String resourceLocation)
Returns an InputStream to read data from the specified resourceLocation. |
static InputStream |
getInputStreamForResource(String resourceLocation,
Class<?> searchStartPoint)
Returns an InputStream to read data from the specified resourceLocation. |
static URL |
getUrlForResource(String resourceLocation)
Returns a URL to access the specified resourceLocation using IOTools.class as a starting point. |
static URL |
getUrlForResource(String resourceLocation,
Class<?> searchStartPoint)
Returns a URL to access the specified resourceLocation. |
static void |
prependResourceLocator(IOTools.ResourceLocator locator)
Adds the specified locator to the beginning of the list of IOTools.ResourceLocator's to use when searching for resources. |
static byte[] |
readAll(File source)
Reads the entire file and returns all the data read in a byte[]. |
static byte[] |
readAll(InputStream rawIn)
Reads the entire stream and returns all the data read in a byte[]. |
static byte[] |
readAll(Socket socket)
Reads the entire stream of data from the Socket and returns all the data read in a byte[]. |
static byte[] |
readAll(URL source)
Reads the entire stream of data from the URL and returns all the data read in a byte[]. |
static byte[] |
readAllFromFile(String filename)
Reads the entire file and returns all the data read in a byte[]. |
static byte[] |
readAllFromResource(String resourceLocation)
Reads the entire stream from the specified resourceLocation and returns all the data read in a byte[]. |
static byte[] |
readAllFromResource(String resourceLocation,
Class<?> searchStartPoint)
Reads the entire stream from the specified resourceLocation and returns all the data read in a byte[]. |
static String[] |
readAllLines(BufferedReader in)
Reads the entire stream of characters and returns all the lines read in a String[]. |
static String[] |
readAllLines(File source)
Reads the entire file converting bytes to characters using the default InputStreamReader and returns all the lines read in a String[]. |
static String[] |
readAllLines(InputStream rawIn)
Reads the entire stream of bytes converting them to characters using the default InputStreamReader and returns all the lines read in a String[]. |
static String[] |
readAllLines(Reader in)
Reads the entire stream of characters and returns all the lines read in a String[]. |
static String[] |
readAllLines(URL source)
Reads the entire stream of data from the URL converting bytes to characters using the default InputStreamReader and returns all the lines read in a String[]. |
static String[] |
readAllLinesFromFile(String filename)
Reads the entire file converting bytes to characters using the default InputStreamReader and returns all the lines read in a String[]. |
static String[] |
readAllLinesFromResource(String resourceLocation)
Reads the entire stream from the specified resourceLocation and returns all the data read in a String[]. |
static String[] |
readAllLinesFromResource(String resourceLocation,
Class<?> searchStartPoint)
Reads the entire stream from the specified resourceLocation and returns all the data read in a String[]. |
static boolean |
removeResourceLocator(IOTools.ResourceLocator rl)
Removes the specified ResourceLocator from the list if it exists. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int EOS
public static final int DEFAULT_BUFFER_SIZE
| Method Detail |
|---|
public static int copy(InputStream in,
boolean closeInputStream,
OutputStream out,
boolean closeOutputStream,
int transferBufferSize)
throws IOException
in - the stream to read bytes fromcloseInputStream - if true, close the InputStream after reaching
the end-of-stream.out - the stream to write bytes out tocloseOutputStream - if true, close the OutputStream after writing
and flushing the final bytes that were read from the InputStream.transferBufferSize - the byte-size of the internally allocated
buffer.
IOException - if there is a transfer problem
public static int copy(InputStream in,
boolean closeInputStream,
OutputStream out,
boolean closeOutputStream)
throws IOException
DEFAULT_BUFFER_SIZE.
Equivalent to:
return copy(in, closeInputStream,
out, closeOutputStream, DEFAULT_BUFFER_SIZE);
IOExceptioncopy(InputStream, boolean, OutputStream, boolean, int)
public static int copy(InputStream in,
OutputStream out)
throws IOException
DEFAULT_BUFFER_SIZE
and closes both streams after the copy is complete.
Equivalent to:
return copy(in, true, out, true, DEFAULT_BUFFER_SIZE);
IOExceptioncopy(InputStream, boolean, OutputStream, boolean, int)
public static int copy(File source,
File destination)
throws FileNotFoundException,
IOException
DEFAULT_BUFFER_SIZE and
closes both streams after the copy is complete.
If an exception is thrown, any streams that were successfully opened are
automatically closed.
Equivalent to:
return copy(new FileInputStream(source), true,
new FileOutputStream(destination), true,
DEFAULT_BUFFER_SIZE);
FileNotFoundException
IOExceptioncopy(InputStream, boolean, OutputStream, boolean, int)
public static void prependResourceLocator(IOTools.ResourceLocator locator)
throws IllegalArgumentException
IOTools.ResourceLocator's to use when searching for resources.
This is a VM-wide setting. The last locator prepended will be the
first one to be used when looking for resources.
locator - the resource locator to place at the front of the
search locations.
IllegalArgumentException - if null is passed inIOTools.ClassLoaderResourceLocator,
IOTools.ServletResourceLocator,
IOTools.BaseDirectoryResourceLocatorpublic static boolean removeResourceLocator(IOTools.ResourceLocator rl)
prependResourceLocator for more information.
rl - locator to remove
public static URL getUrlForResource(String resourceLocation,
Class<?> searchStartPoint)
throws FileNotFoundException,
IOException
getResource(String path)
method on the Class object passed in is used
as a starting point to locate the requested resource.
After that, IOTools.class is used, and if that still doesn't
work, then String.class is used. If they all fail to be
able to locate the resource, then a FileNotFoundException
is thrown.
resourceLocation - the path to the resource, with or without
a leading /. If the resource is not found using name passed
in, then a / is prefixed and the search is re-attempted.searchStartPoint - the Class to invoke
getResource on first. If null, then this
IOTools class will be used first.
FileNotFoundException - if the specified resource
can not be found by the class loader.
IOException - if there are any other problems
public static URL getUrlForResource(String resourceLocation)
throws FileNotFoundException,
IOException
getUrlForResource(String, Class) for the full explanation.
Equivalent to:
return getUrlForResource(resourceLocation, null);
resourceLocation - the path to the resource, with or without
a leading /. If the resource is not found using name passed
in, then a / is prefixed and the search is re-attempted.
FileNotFoundException - if the specified resource
can not be found by the class loader.
IOException - if there are any other problems
public static InputStream getInputStreamForResource(String resourceLocation,
Class<?> searchStartPoint)
throws FileNotFoundException,
IOException
getUrlForResource(String, Class) for the full explanation.
Equivalent to:
return getUrlForResource(
resourceLocation, searchStartPoint).openStream();
FileNotFoundException
IOException
public static InputStream getInputStreamForResource(String resourceLocation)
throws FileNotFoundException,
IOException
getUrlForResource(String, Class) for the full explanation.
Equivalent to:
return getInputStreamForResource(resourceLocation, null);
FileNotFoundException
IOException
public static byte[] readAll(InputStream rawIn)
throws IOException
rawIn - source of bytes
IOException - if anything goes wrong
public static byte[] readAll(File source)
throws FileNotFoundException,
IOException
return readAll(new FileInputStream(source));
FileNotFoundException
IOException
public static byte[] readAllFromFile(String filename)
throws FileNotFoundException,
IOException
return readAll(new FileInputStream(source));
FileNotFoundException
IOException
public static byte[] readAll(URL source)
throws IOException
return readAll(source.openStream());
IOException
public static byte[] readAllFromResource(String resourceLocation,
Class<?> searchStartPoint)
throws FileNotFoundException,
IOException
getResource(String path)
method on the Class object passed in is used
to locate the requested resource.
See getUrlForResource(String, Class) for the full explanation of how
the search for the URL is performed.
Equivalent to:
returnreadAll(getInputStreamForResource(resourceLocation, searchStartPoint));
resourceLocation - the path to the resourcesearchStartPoint - the Class to invoke
getResource. If null, IOTools.class is used.
FileNotFoundException - if the specified resource
can not be found by the class loader.
IOException - if there are problems reading the data
public static byte[] readAllFromResource(String resourceLocation)
throws FileNotFoundException,
IOException
getUrlForResource(String, Class) for the full explanation of how
the search for the URL is performed.
Equivalent to:
returnreadAll(getInputStreamForResource(resourceLocation));
resourceLocation - the path to the resource
FileNotFoundException - if the specified resource
can not be found by the class loader.
IOException - if there are problems reading the data
public static byte[] readAll(Socket socket)
throws IOException
return readAll(socket.getInputStream());
IOException
public static String[] readAllLines(BufferedReader in)
throws IOException
in - source of characters
IOException - if anything goes wrong
public static String[] readAllLines(Reader in)
throws IOException
in - source of characters
IOException - if anything goes wrong
public static String[] readAllLines(InputStream rawIn)
throws IOException
rawIn - source of bytes
IOException - if anything goes wrong
public static String[] readAllLines(File source)
throws FileNotFoundException,
IOException
source - file to read from
IOException - if anything goes wrong
FileNotFoundException
public static String[] readAllLinesFromFile(String filename)
throws FileNotFoundException,
IOException
filename - file to read from
IOException - if anything goes wrong
FileNotFoundException
public static String[] readAllLines(URL source)
throws IOException
source - url to read from
IOException - if anything goes wrong
public static String[] readAllLinesFromResource(String resourceLocation,
Class<?> searchStartPoint)
throws FileNotFoundException,
IOException
getResource(String path)
method on the Class object passed in is used
to locate the requested resource.
See getUrlForResource(String, Class) for the full explanation of how
the search for the URL is performed.
Equivalent to:
returnreadAllLines(getInputStreamForResource(resourceLocation, searchStartPoint));
resourceLocation - the path to the resourcesearchStartPoint - the Class to invoke
getResource. If null, IOTools.class is used.
FileNotFoundException - if the specified resource
can not be found by the class loader.
IOException - if there are problems reading the data
public static String[] readAllLinesFromResource(String resourceLocation)
throws FileNotFoundException,
IOException
getUrlForResource(String, Class) for the full explanation of how
the search for the URL is performed.
Equivalent to:
returnreadAllLines(getInputStreamForResource(resourceLocation));
resourceLocation - the path to the resource
FileNotFoundException - if the specified resource
can not be found by the class loader.
IOException - if there are problems reading the datapublic static BufferedWriter createBufferedWriter(OutputStream rawOut)
rawOut - unbuffered destination for the bytes
public static BufferedWriter createBufferedWriter(File destination)
throws FileNotFoundException,
IOException
return createBufferedWriter(new FileOutputStream(destination));
FileNotFoundException
IOException
public static BufferedWriter createBufferedWriterToFile(String filename)
throws FileNotFoundException,
IOException
return createBufferedWriter(new FileOutputStream(filename));
FileNotFoundException
IOException
public static BufferedWriter createBufferedWriter(Socket socket)
throws IOException
return createBufferedWriter(socket.getOutputStream());
IOExceptionpublic static BufferedReader createBufferedReader(InputStream rawIn)
rawIn - source of the bytes
public static BufferedReader createBufferedReader(File source)
throws FileNotFoundException,
IOException
return createBufferedReader(new FileInputStream(source));
FileNotFoundException
IOException
public static BufferedReader createBufferedReaderFromFile(String filename)
throws FileNotFoundException,
IOException
return createBufferedReader(new FileInputStream(filename));
FileNotFoundException
IOException
public static BufferedReader createBufferedReader(URL source)
throws IOException
return createBufferedReader(source.openStream());
IOException
public static BufferedReader createBufferedReaderFromResource(String resourceLocation,
Class<?> searchStartPoint)
throws FileNotFoundException,
IOException
getResource(String path)
method on the Class object passed in is used
to locate the requested resource.
See getUrlForResource(String, Class) for the full explanation of how
the search for the URL is performed.
Equivalent to:
returncreateBufferedReader(getInputStreamForResource(resourceLocation, searchStartPoint));
resourceLocation - the path to the resourcesearchStartPoint - the Class to invoke
getResource. If null, IOTools.class is used.
FileNotFoundException - if the specified resource
can not be found by the class loader.
IOException - if there are problems reading the data
public static BufferedReader createBufferedReaderFromResource(String resourceLocation)
throws FileNotFoundException,
IOException
getUrlForResource(String, Class) for the full explanation of how
the search for the URL is performed.
Equivalent to:
returncreateBufferedReader(getInputStreamForResource(resourceLocation));
resourceLocation - the path to the resource
FileNotFoundException - if the specified resource
can not be found by the class loader.
IOException - if there are problems reading the data
public static BufferedReader createBufferedReader(Socket socket)
throws IOException
return createBufferedReader(socket.getInputStream());
IOExceptionpublic static DataOutputStream createDataOutputStream(OutputStream rawOut)
rawOut - unbuffered destination for the bytes
public static DataOutputStream createDataOutputStream(File destination)
throws FileNotFoundException,
IOException
return createDataOutputStream(new FileOutputStream(destination));
FileNotFoundException
IOException
public static DataOutputStream createDataOutputStreamToFile(String filename)
throws FileNotFoundException,
IOException
return createDataOutputStream(new FileOutputStream(filename));
FileNotFoundException
IOException
public static DataOutputStream createDataOutputStream(Socket socket)
throws IOException
return createDataOutputStream(socket.getOutputStream());
IOExceptionpublic static DataInputStream createDataInputStream(InputStream rawIn)
rawIn - unbuffered source of the bytes
public static DataInputStream createDataInputStream(File source)
throws FileNotFoundException,
IOException
return createDataInputStream(new FileInputStream(source));
FileNotFoundException
IOException
public static DataInputStream createDataInputStreamFromFile(String filename)
throws FileNotFoundException,
IOException
return createDataInputStream(new FileInputStream(filename));
FileNotFoundException
IOException
public static DataInputStream createDataInputStream(URL source)
throws IOException
return createDataInputStream(source.openStream());
IOException
public static DataInputStream createDataInputStreamFromResource(String resourceLocation,
Class<?> searchStartPoint)
throws FileNotFoundException,
IOException
getResource(String path)
method on the Class object passed in is used
to locate the requested resource.
See getUrlForResource(String, Class) for the full explanation of how
the search for the URL is performed.
Equivalent to:
returncreateDataInputStream(getInputStreamForResource(resourceLocation, searchStartPoint));
resourceLocation - the path to the resourcesearchStartPoint - the Class to invoke
getResource. If null, IOTools.class is used.
FileNotFoundException - if the specified resource
can not be found by the class loader.
IOException - if there are problems reading the data
public static DataInputStream createDataInputStreamFromResource(String resourceLocation)
throws FileNotFoundException,
IOException
getUrlForResource(String, Class) for the full explanation of how
the search for the URL is performed.
Equivalent to:
returncreateDataInputStream(getInputStreamForResource(resourceLocation));
resourceLocation - the path to the resource
FileNotFoundException - if the specified resource
can not be found by the class loader.
IOException - if there are problems reading the data
public static DataInputStream createDataInputStream(Socket socket)
throws IOException
return createDataInputStream(socket.getInputStream());
IOException
public static ObjectOutputStream createObjectOutputStream(OutputStream rawOut)
throws IOException
rawOut - unbuffered destination for the bytes
IOException
public static ObjectOutputStream createObjectOutputStream(File destination)
throws FileNotFoundException,
IOException
return createObjectOutputStream(new FileOutputStream(destination));
FileNotFoundException
IOException
public static ObjectOutputStream createObjectOutputStreamToFile(String filename)
throws FileNotFoundException,
IOException
return createObjectOutputStream(new FileOutputStream(filename));
FileNotFoundException
IOException
public static ObjectOutputStream createObjectOutputStream(Socket socket)
throws IOException
return createObjectOutputStream(socket.getOutputStream());
IOException
public static ObjectInputStream createObjectInputStream(InputStream rawIn)
throws IOException
rawIn - unbuffered source of the bytes
IOException
public static ObjectInputStream createObjectInputStream(File source)
throws FileNotFoundException,
IOException
return createObjectInputStream(new FileInputStream(source));
FileNotFoundException
IOException
public static ObjectInputStream createObjectInputStreamFromFile(String filename)
throws FileNotFoundException,
IOException
return createObjectInputStream(new FileInputStream(filename));
FileNotFoundException
IOException
public static ObjectInputStream createObjectInputStream(URL source)
throws IOException
return createObjectInputStream(source.openStream());
IOException
public static ObjectInputStream createObjectInputStreamFromResource(String resourceLocation,
Class<?> searchStartPoint)
throws FileNotFoundException,
IOException
getResource(String path)
method on the Class object passed in is used
to locate the requested resource.
See getUrlForResource(String, Class) for the full explanation of how
the search for the URL is performed.
Equivalent to:
returncreateObjectInputStream(getInputStreamForResource(resourceLocation, searchStartPoint));
resourceLocation - the path to the resourcesearchStartPoint - the Class to invoke
getResource. If null, IOTools.class is used.
FileNotFoundException - if the specified resource
can not be found by the class loader.
IOException - if there are problems reading the data
public static ObjectInputStream createObjectInputStreamFromResource(String resourceLocation)
throws FileNotFoundException,
IOException
getUrlForResource(String, Class) for the full explanation of how
the search for the URL is performed.
Equivalent to:
returncreateObjectInputStream(getInputStreamForResource(resourceLocation));
resourceLocation - the path to the resource
FileNotFoundException - if the specified resource
can not be found by the class loader.
IOException - if there are problems reading the data
public static ObjectInputStream createObjectInputStream(Socket socket)
throws IOException
return createObjectInputStream(socket.getInputStream());
IOException
public static IOTools.ObjectStreamPair createObjectStreamsForServer(InputStream rawIn,
OutputStream rawOut)
throws IOException
IOException
public static IOTools.ObjectStreamPair createObjectStreamsForClient(InputStream rawIn,
OutputStream rawOut)
throws IOException
IOException
public static IOTools.ObjectStreamPair createObjectStreamsAsync(InputStream rawIn,
OutputStream rawOut)
throws IOException
createObjectStreamsForServer(InputStream, OutputStream) or
createObjectStreamsForClient(InputStream, OutputStream), so
this method should only be used when it is unknown if the far end will
be creating the streams in a cooperative order.
IOException
public static IOTools.ObjectStreamPair createObjectStreamsForServer(Socket socket)
throws IOException
return createObjectStreamsForServer(
socket.getInputStream(), socket.getOutputStream());
IOException
public static IOTools.ObjectStreamPair createObjectStreamsForClient(Socket socket)
throws IOException
return createObjectStreamsForClient(
socket.getInputStream(), socket.getOutputStream());
IOException
public static IOTools.ObjectStreamPair createObjectStreamsAsync(Socket socket)
throws IOException
createObjectStreamsForServer(Socket) or
createObjectStreamsForClient(Socket), so
this method should only be used when it is unknown if the far end will
be creating the streams in a cooperative order.
Equivalent to:
return createObjectStreamsAsync(
socket.getInputStream(), socket.getOutputStream());
IOExceptionpublic static void closeQuietly(InputStream in)
public static void closeQuietly(OutputStream out)
public static void closeQuietly(InputStream in,
OutputStream out)
closeQuietly(out); closeQuietly(in);
public static void closeQuietly(Reader in)
public static void closeQuietly(Writer out)
public static void closeQuietly(Socket socket)
public static void closeQuietly(Socket socket,
InputStream in,
OutputStream out)
closeQuietly(out); closeQuietly(in); closeQuietly(socket);
public static void closeQuietly(Socket socket,
Reader in,
Writer out)
closeQuietly(out); closeQuietly(in); closeQuietly(socket);
public static void closeQuietly(ServerSocket ss)
|
ProgramixGenericLib v5.0.1 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||