Package org.aoju.bus.core.toolkit
Class StreamKit
java.lang.Object
org.aoju.bus.core.toolkit.StreamKit
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidappendWriteAndClose(File f, String text) static BufferedInputStreambuff(InputStream ins) 为一个输入流包裹一个缓冲流 如果这个输入流本身就是缓冲流,则直接返回static BufferedOutputStreambuff(OutputStream ops) 为一个输出流包裹一个缓冲流 如果这个输出流本身就是缓冲流,则直接返回static BufferedReader为一个文本输入流包裹一个缓冲流 如果这个输入流本身就是缓冲流,则直接返回static BufferedWriter为一个文本输出流包裹一个缓冲流 如果这个文本输出流本身就是缓冲流,则直接返回static voidcopy(InputStream in, OutputStream out) static voidcopy(InputStream in, OutputStream out, byte[] buf) static voidcopy(InputStream in, OutputStream out, int len) static voidcopy(InputStream in, OutputStream out, int len, byte[] buf) static voidcopy(InputStream in, OutputStream out, int len, int swapBytes) static voidcopy(InputStream in, OutputStream out, int len, int swapBytes, byte[] buf) static booleanequals(InputStream ina, InputStream inb) 判断两个输入流是否严格相等static OutputStream根据一个文件建立一个输出流static InputStreamfindFileAsStream(String path, Class<?> klass, String enc) 获取输出流static voidstatic String按行读取文件为Stream按行读取文件为Streamstatic <T> Stream<T> static <T> Stream<T> 按行读取文件为Stream按行读取文件为Streamstatic <T> Stream<T> static <T> Stream<T> static <T> Stream<T> of(T... array) static InputStreamopenFileOrURL(String name) static byte[]read(InputStream ins) 读取一个输入流中所有的字节static StringBuilder从一个文本流中读取全部内容并返回static intread(Reader reader, StringBuilder sb) 从一个文本流中读取全部内容并写入缓冲static String从一个文本输入流读取所有内容,并将该流关闭static byte[]readAndClose(InputStream ins) 读取一个输入流中所有的字节,并关闭输入流static intreadAndClose(InputStreamReader reader, StringBuilder sb) 从一个文本流中读取全部内容并写入缓冲static StringreadAndClose(Reader reader) 从一个文本流中读取全部内容并返回static intreadAvailable(InputStream in, byte[] b, int off, int len) static voidreadFully(InputStream in, byte[] b, int off, int len) static StringreadText(InputStream in) static StringreadText(InputStream in, String encoding) static StringreadText(InputStream in, String encoding, int bufferSize) static Stringstatic Stringstatic boolean关闭一个可关闭对象,可以接受 null 如果成功关闭,返回 true,发生异常 返回 falsestatic void安全刷新一个可刷新的对象,可接受 nullstatic voidskipFully(InputStream in, long n) static InputStreamutf8filte(InputStream in) 判断并移除UTF-8的BOM头static Readerutf8r(InputStream is) static Writerutf8w(OutputStream os) static InputStreamwrap(byte[] bytes) static voidwrite(OutputStream ops, byte[] bytes) 将一个字节数组写入一个输出流static longwrite(OutputStream ops, InputStream ins) 将输入流写入一个输出流 块大小为 8192static longwrite(OutputStream ops, InputStream ins, int bufferSize) 将输入流写入一个输出流static long将文本输入流写入一个文本输出流 块大小为 8192static voidwrite(Writer writer, CharSequence cs) 将一段文本全部写入一个writerstatic voidwriteAndClose(OutputStream ops, byte[] bytes) 将一个字节数组写入一个输出流static longwriteAndClose(OutputStream ops, InputStream ins) 将输入流写入一个输出流 块大小为 8192static longwriteAndClose(OutputStream ops, InputStream ins, int buf) static longwriteAndClose(Writer writer, Reader reader) 将文本输入流写入一个文本输出流 块大小为 8192static voidwriteAndClose(Writer writer, CharSequence cs) 将一段文本全部写入一个writer
-
Constructor Details
-
StreamKit
public StreamKit()
-
-
Method Details
-
equals
判断两个输入流是否严格相等- Parameters:
ina- 输入流inb- 输入流- Returns:
- the boolean
- Throws:
IOException- 异常
-
read
从一个文本流中读取全部内容并返回注意,它并不会关闭输出流
- Parameters:
reader- 文本输出流- Returns:
- 文本内容
- Throws:
IOException- 异常
-
read
读取一个输入流中所有的字节- Parameters:
ins- 输入流,必须支持 available()- Returns:
- 一个字节数组
- Throws:
IOException- 异常
-
read
从一个文本流中读取全部内容并写入缓冲- Parameters:
reader- 文本输出流sb- 输出的文本缓冲- Returns:
- 读取的字符数量
- Throws:
IOException- 异常
-
readAll
-
readText
- Throws:
IOException
-
readText
- Throws:
IOException
-
readText
- Throws:
IOException
-
readText
- Throws:
IOException
-
readText
- Throws:
IOException
-
write
将一段文本全部写入一个writer注意,它并不会关闭输出流
- Parameters:
writer- 操作器cs- 文本- Throws:
IOException- 异常
-
write
将输入流写入一个输出流 块大小为 8192注意,它并不会关闭输入/出流
- Parameters:
ops- 输出流ins- 输入流- Returns:
- 写入的字节数
- Throws:
IOException- 异常
-
write
将输入流写入一个输出流注意,它并不会关闭输入/出流
- Parameters:
ops- 输出流ins- 输入流bufferSize- 缓冲块大小- Returns:
- 写入的字节数
- Throws:
IOException- 异常
-
write
将文本输入流写入一个文本输出流 块大小为 8192注意,它并不会关闭输入/出流
- Parameters:
writer- 输出流reader- 输入流- Returns:
- the long
- Throws:
IOException- 异常
-
write
将一个字节数组写入一个输出流注意,它并不会关闭输出流
- Parameters:
ops- 输出流bytes- 字节数组- Throws:
IOException- 异常
-
readAndClose
-
readAndClose
读取一个输入流中所有的字节,并关闭输入流- Parameters:
ins- 输入流,必须支持 available()- Returns:
- 一个字节数组
-
readAndClose
从一个文本流中读取全部内容并写入缓冲注意,它会关闭输出流
- Parameters:
reader- 文本输出流sb- 输出的文本缓冲- Returns:
- 读取的字符数量
-
writeAndClose
将一段文本全部写入一个writer注意,它会关闭输出流
- Parameters:
writer- 输出流cs- 文本
-
writeAndClose
将输入流写入一个输出流 块大小为 8192注意,它会关闭输入/出流
- Parameters:
ops- 输出流ins- 输入流- Returns:
- 写入的字节数
-
writeAndClose
-
writeAndClose
将一个字节数组写入一个输出流注意,它会关闭输出流
- Parameters:
ops- 输出流bytes- 字节数组
-
writeAndClose
-
buff
为一个文本输入流包裹一个缓冲流 如果这个输入流本身就是缓冲流,则直接返回- Parameters:
reader- 文本输入流- Returns:
- 缓冲文本输入流
-
buff
为一个文本输出流包裹一个缓冲流 如果这个文本输出流本身就是缓冲流,则直接返回- Parameters:
writer- 文本输出流- Returns:
- 缓冲文本输出流
-
buff
为一个输入流包裹一个缓冲流 如果这个输入流本身就是缓冲流,则直接返回- Parameters:
ins- 输入流- Returns:
- 缓冲输入流
-
buff
为一个输出流包裹一个缓冲流 如果这个输出流本身就是缓冲流,则直接返回- Parameters:
ops- 输出流- Returns:
- 缓冲输出流
-
readFully
- Throws:
IOException
-
skipFully
- Throws:
IOException
-
safeClose
关闭一个可关闭对象,可以接受 null 如果成功关闭,返回 true,发生异常 返回 false- Parameters:
cb- 可关闭对象- Returns:
- 是否成功关闭
-
safeFlush
-
utf8r
-
utf8w
-
utf8filte
判断并移除UTF-8的BOM头- Parameters:
in- 输入流- Returns:
- 输入流
-
fileOut
-
wrap
-
appendWriteAndClose
-
findFileAsStream
获取输出流- Parameters:
path- 文件路径klass- 参考的类, -- 会用这个类的 ClassLoaderenc- 文件路径编码- Returns:
- 输出流
-
readAvailable
- Throws:
IOException
-
nextLineTrim
- Throws:
IOException
-
copy
- Throws:
IOException
-
copy
- Throws:
IOException
-
copy
- Throws:
IOException
-
copy
- Throws:
IOException
-
copy
public static void copy(InputStream in, OutputStream out, int len, int swapBytes, byte[] buf) throws IOException - Throws:
IOException
-
copy
public static void copy(InputStream in, OutputStream out, int len, int swapBytes) throws IOException - Throws:
IOException
-
openFileOrURL
- Throws:
IOException
-
io
- Throws:
IOException
-
of
-
of
-
of
-
of
-
of
-
of
-
of
-
of
-
of
-