Package org.fugerit.java.core.io
Class StreamIO
- java.lang.Object
-
- org.fugerit.java.core.io.StreamIO
-
public class StreamIO extends Object
StreamIO provides API for managing stream, reader an writer.
- Author:
- fugerit
-
-
Field Summary
Fields Modifier and Type Field Description static int
BUFFERSIZE_DEFAULT
Default size buffer.static int
BUFFERSIZE_HIGH
Big size buffer.static int
BUFFERSIZE_LOW
Small size buffer.static int
BUFFERSIZE_MEDIUM
Medium size buffer.static int
BUFFERSIZE_NOBUFFER
No buffer at all (size = 1)static int
MODE_CLOSE_BOTH
Invoke close() method on both source and destination at the end of operation.static int
MODE_CLOSE_IN_ONLY
Invoke close() method on ource only at the end of operation.static int
MODE_CLOSE_NONE
Don't invoke close() method on source and destination at the end of operation.static int
MODE_CLOSE_OUT_ONLY
Invoke close() method on destination only at the end of operation.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static long
pipeChar(Reader src, Writer dst, int modeClose)
Pipe the content of a java.io.InputStream into a java.io.OutputStream.static long
pipeCharCloseBoth(Reader src, Writer dst)
Pipe the content of a java.io.InputStream into a java.io.OutputStream.static long
pipeStream(InputStream src, OutputStream dst, int modeClose)
Pipe the content of a java.io.Reader into a java.io.Writer.static long
pipeStreamCloseBoth(InputStream src, OutputStream dst)
Pipe the content of a java.io.Reader into a java.io.Writer.static byte[]
readBytes(InputStream src)
Read an InputStream as a byte array.static String
readString(InputStream src)
Read an InputStream as a String.static String
readString(Reader src)
Read an Reader as a String.
-
-
-
Field Detail
-
MODE_CLOSE_NONE
public static final int MODE_CLOSE_NONE
Don't invoke close() method on source and destination at the end of operation.- See Also:
- Constant Field Values
-
MODE_CLOSE_BOTH
public static final int MODE_CLOSE_BOTH
Invoke close() method on both source and destination at the end of operation.- See Also:
- Constant Field Values
-
MODE_CLOSE_IN_ONLY
public static final int MODE_CLOSE_IN_ONLY
Invoke close() method on ource only at the end of operation.- See Also:
- Constant Field Values
-
MODE_CLOSE_OUT_ONLY
public static final int MODE_CLOSE_OUT_ONLY
Invoke close() method on destination only at the end of operation.- See Also:
- Constant Field Values
-
BUFFERSIZE_LOW
public static final int BUFFERSIZE_LOW
Small size buffer.- See Also:
- Constant Field Values
-
BUFFERSIZE_MEDIUM
public static final int BUFFERSIZE_MEDIUM
Medium size buffer.- See Also:
- Constant Field Values
-
BUFFERSIZE_HIGH
public static final int BUFFERSIZE_HIGH
Big size buffer.- See Also:
- Constant Field Values
-
BUFFERSIZE_DEFAULT
public static final int BUFFERSIZE_DEFAULT
Default size buffer.BUFFERSIZE_MEDIUM
- See Also:
- Constant Field Values
-
BUFFERSIZE_NOBUFFER
public static final int BUFFERSIZE_NOBUFFER
No buffer at all (size = 1)- See Also:
- Constant Field Values
-
-
Method Detail
-
readString
public static String readString(InputStream src) throws IOException
Read an InputStream as a String.
- Parameters:
src
- the input stream- Returns:
- the String
- Throws:
IOException
- in case of troubles during the operation
-
readString
public static String readString(Reader src) throws IOException
Read an Reader as a String.
- Parameters:
src
- the input stream- Returns:
- the String
- Throws:
IOException
- in case of troubles during the operation
-
readBytes
public static byte[] readBytes(InputStream src) throws IOException
Read an InputStream as a byte array.
- Parameters:
src
- the input stream- Returns:
- the byte array
- Throws:
IOException
- in case of troubles during the operation
-
pipeChar
public static long pipeChar(Reader src, Writer dst, int modeClose) throws IOException
Pipe the content of a java.io.InputStream into a java.io.OutputStream.
- Parameters:
src
- the sourcedst
- the destinationmodeClose
- the mode for closing source and/or destination- Returns:
- the number of char read/written
- Throws:
IOException
- in case of troubles during the operation
-
pipeCharCloseBoth
public static long pipeCharCloseBoth(Reader src, Writer dst) throws IOException
Pipe the content of a java.io.InputStream into a java.io.OutputStream.
- Parameters:
src
- the sourcedst
- the destination- Returns:
- the number of char read/written
- Throws:
IOException
- in case of troubles during the operation
-
pipeStream
public static long pipeStream(InputStream src, OutputStream dst, int modeClose) throws IOException
Pipe the content of a java.io.Reader into a java.io.Writer.
- Parameters:
src
- the sourcedst
- the destinationmodeClose
- the mode for closing source and/or destination- Returns:
- the number of byte read/written
- Throws:
IOException
- in case of troubles during the operation
-
pipeStreamCloseBoth
public static long pipeStreamCloseBoth(InputStream src, OutputStream dst) throws IOException
Pipe the content of a java.io.Reader into a java.io.Writer.
- Parameters:
src
- the sourcedst
- the destination- Returns:
- the number of byte read/written
- Throws:
IOException
- in case of troubles during the operation
-
-