类 IoUtils
- java.lang.Object
-
- com.alibaba.nacos.common.utils.IoUtils
-
public class IoUtils extends java.lang.ObjectIO related tool methods.- 作者:
- nacos
-
-
构造器概要
构造器 构造器 说明 IoUtils()
-
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static voidcleanDirectory(java.io.File directory)清理目录下的内容.static voidcloseQuietly(java.io.Closeable closeable)Close closable object quietly.static voidcloseQuietly(java.io.Closeable... closeable)static voidcloseQuietly(java.net.HttpURLConnection connection)Close http connection quietly.static longcopy(java.io.InputStream input, java.io.OutputStream output)Copy data.static longcopy(java.io.Reader input, java.io.Writer output)Copy data.static voidcopyFile(java.lang.String source, java.lang.String target)Copy File.static voiddelete(java.io.File fileOrDir)Delete file or dir.static booleanisGzipStream(byte[] bytes)Judge whether is Gzip stream.static java.util.List<java.lang.String>readLines(java.io.Reader input)Read lines.private static java.io.BufferedReadertoBufferedReader(java.io.Reader reader)static java.lang.StringtoString(java.io.InputStream input, java.lang.String encoding)To string from stream.static java.lang.StringtoString(java.io.Reader reader)To string from reader.static byte[]tryCompress(java.lang.String str, java.lang.String encoding)Try compress by GZIP for string.static byte[]tryDecompress(byte[] raw)Try decompress by GZIP from byte array.static byte[]tryDecompress(java.io.InputStream raw)Try decompress by GZIP from stream.static voidwriteStringToFile(java.io.File file, java.lang.String data, java.lang.String encoding)Write string to a file.
-
-
-
方法详细资料
-
tryDecompress
public static byte[] tryDecompress(java.io.InputStream raw) throws java.io.IOExceptionTry decompress by GZIP from stream.- 参数:
raw- compress stream- 返回:
- byte array after decompress
- 抛出:
java.io.IOException
-
tryDecompress
public static byte[] tryDecompress(byte[] raw) throws java.lang.ExceptionTry decompress by GZIP from byte array.- 参数:
raw- compressed byte array- 返回:
- byte array after decompress
- 抛出:
java.lang.Exception- exception
-
tryCompress
public static byte[] tryCompress(java.lang.String str, java.lang.String encoding)Try compress by GZIP for string.- 参数:
str- strings to be compressed.encoding- encoding.- 返回:
- byte[]
-
toBufferedReader
private static java.io.BufferedReader toBufferedReader(java.io.Reader reader)
-
writeStringToFile
public static void writeStringToFile(java.io.File file, java.lang.String data, java.lang.String encoding) throws java.io.IOExceptionWrite string to a file.- 参数:
file- filedata- stringencoding- encoding of string- 抛出:
java.io.IOException- io exception
-
readLines
public static java.util.List<java.lang.String> readLines(java.io.Reader input) throws java.io.IOExceptionRead lines.- 参数:
input- reader- 返回:
- list of line
- 抛出:
java.io.IOException- io exception
-
toString
public static java.lang.String toString(java.io.InputStream input, java.lang.String encoding) throws java.io.IOExceptionTo string from stream.- 参数:
input- streamencoding- charset of stream- 返回:
- string
- 抛出:
java.io.IOException- io exception
-
toString
public static java.lang.String toString(java.io.Reader reader) throws java.io.IOExceptionTo string from reader.- 参数:
reader- reader- 返回:
- string
- 抛出:
java.io.IOException- io exception
-
copy
public static long copy(java.io.Reader input, java.io.Writer output) throws java.io.IOExceptionCopy data.- 参数:
input- sourceoutput- target- 返回:
- copy size
- 抛出:
java.io.IOException- io exception
-
copy
public static long copy(java.io.InputStream input, java.io.OutputStream output) throws java.io.IOExceptionCopy data.- 参数:
input- sourceoutput- target- 返回:
- copy size
- 抛出:
java.io.IOException- io exception
-
delete
public static void delete(java.io.File fileOrDir) throws java.io.IOExceptionDelete file or dir.If is dir, clean directory, do not delete dir.
If is file, delete file.
- 参数:
fileOrDir- file or dir- 抛出:
java.io.IOException- io exception
-
cleanDirectory
public static void cleanDirectory(java.io.File directory) throws java.io.IOException清理目录下的内容. Clean content under directory.- 参数:
directory- directory- 抛出:
java.io.IOException- io exception
-
copyFile
public static void copyFile(java.lang.String source, java.lang.String target) throws java.io.IOExceptionCopy File.- 参数:
source- source file pathtarget- target file path- 抛出:
java.io.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
public static void closeQuietly(java.net.HttpURLConnection connection)
Close http connection quietly.- 参数:
connection- http connection
-
closeQuietly
public static void closeQuietly(java.io.Closeable closeable)
Close closable object quietly.- 参数:
closeable- http connection
-
closeQuietly
public static void closeQuietly(java.io.Closeable... closeable)
-
-