类 IoUtils


  • public class IoUtils
    extends Object
    作者:
    tag
    • 构造器详细资料

      • IoUtils

        public IoUtils()
    • 方法详细资料

      • download

        public static byte[] download​(String urlStr)
                               throws IOException
        读取远程文件字节流
        参数:
        urlStr - 远程文件地址
        返回:
        读取回的字节流
        抛出:
        IOException
      • readInputStream

        public static byte[] readInputStream​(InputStream inputStream)
                                      throws IOException
        从输入流中获取字节数组
        参数:
        inputStream - 输入流
        返回:
        读取的字节数组
        抛出:
        IOException
      • read

        public static String read​(String path)
                           throws Exception
        读取本地指定路径的文件信息(不换行)
        参数:
        path - 文件路径
        返回:
        文件内容
        抛出:
        Exception
      • readRealPath

        public static String readRealPath​(InputStream stream)
                                   throws Exception
        读取本地指定绝对路径的文件信息
        参数:
        stream - 文件的绝对路径
        返回:
        文件内容
        抛出:
        Exception
      • readBytesToString

        public static String readBytesToString​(InputStream is)
        以字节流的方式读取到字符串。
        参数:
        is - 输入流
        返回:
        字符串
      • readBytesToString

        public static String readBytesToString​(InputStream is,
                                               String charsetName)
        以字节流的方式读取到字符串。
        参数:
        is - 输入流
        charsetName - 字符集
        返回:
        字符串
      • readBytesToString

        public static String readBytesToString​(File file,
                                               String charsetName)
        以字节流的方式从文件中读取字符串
        参数:
        file - 文件
        charsetName - 字符集
        返回:
        字符串
      • readBytesToString

        public static String readBytesToString​(File file)
        以字节流的方式从文件中读取字符串。
        参数:
        file - 文件
        返回:
        字符串
      • readBytes

        public static byte[] readBytes​(InputStream is)
        以字节流的方式读取到字符串。
        参数:
        is - 输入流
        返回:
        字节数组
      • readChars

        public static char[] readChars​(InputStream is,
                                       String charsetName)
        以字符流的方式读取到字符串。
        参数:
        is - 输入流
        charsetName - 编码
        返回:
        字符数组
      • readCharsToString

        public static String readCharsToString​(File file)
        以字符流的方式读取到字符串。
        参数:
        file - 文件
        返回:
        字符串
      • readCharsToString

        public static String readCharsToString​(File file,
                                               String charset)
        以字节流的方式读取到字符串。
        参数:
        file - 文件
        charset - 字符集
        返回:
        字符串
      • readCharsToString

        public static String readCharsToString​(InputStream is)
        以字符流的方式读取到字符串。默认编码
        参数:
        is - 输入流
        返回:
        字符串
      • readCharsToString

        public static String readCharsToString​(InputStream is,
                                               String charsetName)
        以字符流的方式读取到字符串。
        参数:
        is - 输入流
        charsetName - 编码
        返回:
        字符串
      • readBytes

        public static byte[] readBytes​(File file)
        以字节流的方式读取到字符串。
        参数:
        file - 文件
        返回:
        字节数组
      • readChars

        public static char[] readChars​(File file,
                                       String charsetName)
        以字符流的方式读取到字符串。
        参数:
        file - 文件
        charsetName - 编码
        返回:
        字符数组
      • writeBytes

        public static void writeBytes​(OutputStream os,
                                      byte[] text)
        通过字节输出流输出bytes
        参数:
        os - 输出流
        text - 字节数组
      • writeBytes

        public static void writeBytes​(OutputStream os,
                                      byte[] text,
                                      int off,
                                      int lenght)
        通过字节输出流输出bytes
        参数:
        os - 输出流
        text - 字节数组
        off - 数组起始下标
        lenght - 长度
      • writeChars

        public static void writeChars​(OutputStream os,
                                      char[] text,
                                      String charsetName)
        通过字符输出流输出chars
        参数:
        os - 输出流
        text - 字节数组
        charsetName - 编码方式
      • writeChars

        public static void writeChars​(OutputStream os,
                                      char[] text,
                                      int off,
                                      int lenght,
                                      String charsetName)
        通过字符输出流输出chars
        参数:
        os - 输出流
        text - 字节数组
        off - 数组起始下标
        lenght - 长度
        charsetName - 编码方式
      • writeString

        public static void writeString​(File file,
                                       boolean append,
                                       String text)
        将字符串以默认编码写入文件
        参数:
        file - 文件
        text - 字符串
      • writeString

        public static void writeString​(File file,
                                       boolean append,
                                       String text,
                                       int off,
                                       int lenght,
                                       String charsetName)
        将字符串写入文件
        参数:
        file - 文件
        append - 是否追加
        text - 字符串
        off - 起始下标
        lenght - 长度
        charsetName - 编码名称
      • writeString

        public static void writeString​(File file,
                                       String text)
        将字符串以默认编码写入文件
        参数:
        file - 文件
        text - 字符串
      • writeString

        public static void writeString​(File file,
                                       boolean append,
                                       String text,
                                       String charsetName)
        将字符串写入文件(默认覆盖)
        参数:
        file - 文件
        append - 是否追加
        text - 字符串
        charsetName - 编码名称
      • writeString

        public static void writeString​(File file,
                                       String text,
                                       String charsetName)
        将字符串写入文件(默认覆盖)
        参数:
        file - 文件
        text - 字符串
        charsetName - 编码名称
      • writeString

        public static void writeString​(OutputStream os,
                                       String text,
                                       String charsetName)
        字符输出流输出字符串
        参数:
        os - 输出流
        text - 字符串
        charsetName - 编码
      • writeString

        public static void writeString​(OutputStream os,
                                       String text,
                                       int off,
                                       int lenght,
                                       String charsetName)
        字符输出流输出字符串
        参数:
        os - 输出流
        text - 字符串
        off - 起始下标
        lenght - 长度
        charsetName - 编码