public abstract class StreamUtils extends ObjectSE
FileCopyUtils で定義されているものと似ています。すべてのコピー方法は、4096 バイトのブロックサイズを使用します。主にフレームワーク内で使用しますが、アプリケーションコードにも役立ちます。
FileCopyUtils| 修飾子と型 | フィールドと説明 |
|---|---|
static int | BUFFER_SIZE バイトをコピーするときに使用されるデフォルトのバッファサイズ。 |
| コンストラクターと説明 |
|---|
StreamUtils() |
| 修飾子と型 | メソッドと説明 |
|---|---|
static void | copy(byte[] in, OutputStreamSE out) 指定されたバイト配列の内容を指定された OutputStream にコピーします。 |
static int | copy(InputStreamSE in, OutputStreamSE out) 指定された InputStream の内容を指定された OutputStream にコピーします。 |
static void | copy(StringSE in, CharsetSE charset, OutputStreamSE out) 指定された文字列の内容を指定された OutputStream にコピーします。 |
static long | copyRange(InputStreamSE in, OutputStreamSE out, long start, long end) 特定の InputStream のコンテンツの範囲を特定の OutputStream にコピーします。 |
static byte[] | copyToByteArray(InputStreamSE in) 指定された InputStream の内容を新しいバイト配列にコピーします。 |
static StringSE | copyToString(ByteArrayOutputStreamSE baos, CharsetSE charset) 指定された ByteArrayOutputStreamSE の内容を StringSE にコピーします。 |
static StringSE | copyToString(InputStreamSE in, CharsetSE charset) 指定された InputStream の内容を文字列にコピーします。 |
static int | drain(InputStreamSE in) 指定された InputStream の残りのコンテンツを排出します。 |
static InputStreamSE | emptyInput() 効率的な空の InputStreamSE を返します。 |
static InputStreamSE | nonClosing(InputStreamSE in)close()SE を呼び出しても効果がない、指定された InputStreamSE のバリアントを返します。 |
static OutputStreamSE | nonClosing(OutputStreamSE out)close()SE を呼び出しても効果がない、指定された OutputStreamSE のバリアントを返します。 |
cloneSE, equalsSE, finalizeSE, getClassSE, hashCodeSE, notifySE, notifyAllSE, toStringSE, waitSE, waitSE, waitSEpublic static final int BUFFER_SIZE
public static byte[] copyToByteArray(@Nullable InputStreamSE in) throws IOExceptionSE
終了してもストリームを開いたままにします。
in - コピー元のストリーム (null または空の場合があります)IOExceptionSE - I/O エラーの場合 public static StringSE copyToString(@Nullable InputStreamSE in, CharsetSE charset) throws IOExceptionSE
終了してもストリームを開いたままにします。
in - コピー元の InputStream (null または空の場合があります)charset - バイトのデコードに使用する CharsetSEIOExceptionSE - I/O エラーの場合 public static StringSE copyToString(ByteArrayOutputStreamSE baos, CharsetSE charset)
ByteArrayOutputStreamSE の内容を StringSE にコピーします。 これは new String(baos.toByteArray(), charset) のより効果的な同等物です。
baos - 文字列にコピーされる ByteArrayOutputStream charset - バイトのデコードに使用する CharsetSEpublic static void copy(byte[] in,
OutputStreamSE out)
throws IOExceptionSE終了してもストリームを開いたままにします。
in - コピー元のバイト配列 out - コピー先の OutputStreamIOExceptionSE - I/O エラーの場合 public static void copy(StringSE in, CharsetSE charset, OutputStreamSE out) throws IOExceptionSE
終了してもストリームを開いたままにします。
in - コピー元の文字列 charset - 文字セット out - コピー先の OutputStreamIOExceptionSE - I/O エラーの場合 public static int copy(InputStreamSE in, OutputStreamSE out) throws IOExceptionSE
完了したら、両方のストリームを開いたままにします。
in - コピー元の InputStreamout - コピー先の OutputStreamIOExceptionSE - I/O エラーの場合 public static long copyRange(InputStreamSE in, OutputStreamSE out, long start, long end) throws IOExceptionSE
指定された範囲が InputStream の長さを超える場合、これはストリームの最後までコピーし、コピーされた実際のバイト数を返します。
完了したら、両方のストリームを開いたままにします。
in - コピー元の InputStreamout - コピー先の OutputStreamstart - コピーを開始する位置 end - コピーを終了する位置 IOExceptionSE - I/O エラーの場合 public static int drain(InputStreamSE in) throws IOExceptionSE
完了したら InputStream を開いたままにします。
in - InputStream を排出する IOExceptionSE - I/O エラーの場合 public static InputStreamSE emptyInput()
InputStreamSE を返します。ByteArrayInputStreamSEpublic static InputStreamSE nonClosing(InputStreamSE in)
close()SE を呼び出しても効果がない、指定された InputStreamSE のバリアントを返します。in - InputStream を飾る public static OutputStreamSE nonClosing(OutputStreamSE out)
close()SE を呼び出しても効果がない、指定された OutputStreamSE のバリアントを返します。out - OutputStream を飾る