|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectuk.ac.starlink.util.IOUtils
public class IOUtils
Provides static methods which do miscellaneous input/output tasks.
Method Summary | |
---|---|
static void |
copy(InputStream in,
OutputStream out)
Copies all the bytes from a given input stream to a given output stream. |
static byte[] |
getLineSeparatorBytes()
Returns the platform's line separator as a byte array given the platform's default encoding. |
static String |
getResourceContents(Class clazz,
String name)
Reads a static resource and returns the contents as a string. |
static void |
println(OutputStream out,
String line)
Writes a string to an output stream followed by a new line. |
static byte[] |
readBytes(InputStream in,
int maxLeng)
Reads a number of bytes from a stream. |
static void |
skip(InputStream strm,
long nskip)
Skips over a number of bytes in an InputStream This is implemented using InputStream.skip(long)
but differs from it in that it guarantees to skip the bytes
as specified, or to throw an exception. |
static void |
skipBytes(DataInput strm,
long nskip)
Skips over a number of bytes in a DataInput. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static void skipBytes(DataInput strm, long nskip) throws IOException
DataInput.skipBytes(int)
but differs from it in that it guarantees to skip the bytes
as specified, or to throw an exception.
strm
- the stream to skip throughnskip
- the number of bytes to skip
EOFException
- if the end of file is reached
IOException
- if an I/O error occurs
IllegalArgumentException
- if nskip<0public static void skip(InputStream strm, long nskip) throws IOException
InputStream.skip(long)
but differs from it in that it guarantees to skip the bytes
as specified, or to throw an exception.
strm
- the stream to skip throughnskip
- the number of bytes to skip
EOFException
- if the end of file is reached
IOException
- if an I/O error occurs
IllegalArgumentException
- if nskip<0public static String getResourceContents(Class clazz, String name)
clazz.getResourceAsStream(name)
and is assumed to have ASCII content. The result is cached so that
subsequent calls will return the same value.
If it can't be read, "?" is returned.
This is intended for short files such as version strings.
clazz
- class defining relative location of resourcename
- resource name relative to clazz
Class.getResourceAsStream(java.lang.String)
public static void println(OutputStream out, String line) throws IOException
PrintStream.println()
, an IOException may
be thrown.
out
- destination streamline
- line to write
IOException
public static byte[] getLineSeparatorBytes()
public static void copy(InputStream in, OutputStream out) throws IOException
in
- sourceout
- destination
IOException
public static byte[] readBytes(InputStream in, int maxLeng) throws IOException
in
- input streammaxLeng
- maximum number of bytes to read
IOException
|
Copyright © 2004 CLRC: Central Laboratory of the Research Councils. All rights reserved. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |