类 IoUtils
java.lang.Object
com.alibaba.nacos.common.utils.IoUtils
IO related tool methods.
- 作者:
- nacos
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static voidcleanDirectory(File directory)清理目录下的内容.static voidcloseQuietly(Closeable closeable)Close closable object quietly.static voidcloseQuietly(InputStream input)static voidcloseQuietly(OutputStream output)static voidcloseQuietly(HttpURLConnection connection)Close http connection quietly.static longcopy(InputStream input, OutputStream output)Copy data.static longCopy data.static voidCopy File.static voidDelete file or dir.static booleanisGzipStream(byte[] bytes)Judge whether is Gzip stream.Read lines.static StringtoString(InputStream input, String encoding)To string from stream.static StringTo string from reader.static byte[]tryCompress(String str, String encoding)Try compress by GZIP for string.static byte[]tryDecompress(byte[] raw)Try decompress by GZIP from byte array.static byte[]tryDecompress(InputStream raw)Try decompress by GZIP from stream.static voidwriteStringToFile(File file, String data, String encoding)Write string to a file.
-
构造器详细资料
-
IoUtils
public IoUtils()
-
-
方法详细资料
-
tryDecompress
Try decompress by GZIP from stream.- 参数:
raw- compress stream- 返回:
- byte array after decompress
- 抛出:
IOException- exception
-
tryDecompress
Try decompress by GZIP from byte array.- 参数:
raw- compressed byte array- 返回:
- byte array after decompress
- 抛出:
Exception- exception
-
tryCompress
Try compress by GZIP for string.- 参数:
str- strings to be compressed.encoding- encoding.- 返回:
- byte[]
-
writeStringToFile
Write string to a file.- 参数:
file- filedata- stringencoding- encoding of string- 抛出:
IOException- io exception
-
readLines
Read lines.- 参数:
input- reader- 返回:
- list of line
- 抛出:
IOException- io exception
-
toString
To string from stream.- 参数:
input- streamencoding- charset of stream- 返回:
- string
- 抛出:
IOException- io exception
-
toString
To string from reader.- 参数:
reader- reader- 返回:
- string
- 抛出:
IOException- io exception
-
copy
Copy data.- 参数:
input- sourceoutput- target- 返回:
- copy size
- 抛出:
IOException- io exception
-
copy
Copy data.- 参数:
input- sourceoutput- target- 返回:
- copy size
- 抛出:
IOException- io exception
-
delete
Delete file or dir.If is dir, clean directory, do not delete dir.
If is file, delete file.
- 参数:
fileOrDir- file or dir- 抛出:
IOException- io exception
-
cleanDirectory
清理目录下的内容. Clean content under directory.- 参数:
directory- directory- 抛出:
IOException- io exception
-
copyFile
Copy File.- 参数:
source- source file pathtarget- target file path- 抛出:
IOException- io exception
-
isGzipStream
public static boolean isGzipStream(byte[] bytes)Judge whether is Gzip stream.- 参数:
bytes- byte array- 返回:
- true if is gzip, otherwise false
-
closeQuietly
Close http connection quietly.- 参数:
connection- http connection
-
closeQuietly
-
closeQuietly
-
closeQuietly
Close closable object quietly.- 参数:
closeable- http connection
-