public class IOUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static InputStream |
newRepeatableInputStream(InputStream original)
将一个输入流包装成可重复读的流,同时尽可能地优化性能。
|
static int |
readFully(InputStream source,
byte[] buffer,
int offset,
int length) |
static long |
readLittleEndianLong(InputStream in) |
static byte[] |
readNBytes(InputStream in,
int len)
从输入流中精确读取 len 个字节。
这个方法会阻塞,直到 len 个字节被读取,或者流结束,或者发生 I/O 错误。
|
static void |
transferTo(InputStream inputStream,
OutputStream outputStream) |
public static InputStream newRepeatableInputStream(InputStream original) throws IOException
该方法的行为遵循以下优先级:
RepeatableFileInputStream 包装。DiskSpillingInputStream。
这确保了对任意大小、任意来源的流都提供绝对健壮的可重试性。original - 原始输入流。IOException - 如果在缓存到磁盘的过程中发生 I/O 错误。public static void transferTo(InputStream inputStream, OutputStream outputStream) throws IOException
IOExceptionpublic static byte[] readNBytes(InputStream in, int len) throws IOException
in - 输入流len - 要读取的字节数IOException - 如果发生 I/O 错误EOFException - 如果在读取完 len 个字节之前到达流的末尾public static int readFully(InputStream source, byte[] buffer, int offset, int length) throws IOException
IOExceptionpublic static long readLittleEndianLong(InputStream in) throws IOException
IOExceptionCopyright © 2026 Alibaba Cloud Computing. All rights reserved.