从文件中读取每一行数据

@param <T> 集合类型
@param file 文件路径
@param charset 字符集
@param collection 集合
@return 文件中的每行内容的集合
@throws IORuntimeException IO异常
481675
public static <T extends Collection<String>> T readLines(File file, String charset, T collection) throws IORuntimeException {
		return FileReader.create(file, CharsetUtil.charset(charset)).readLines(collection);
	}
653953
public static <T extends Collection<String>> T readLines(Reader reader, final T collection) throws IORuntimeException {
		readLines(reader, new LineHandler() {
			@Override
			public void handle(String line) {
				collection.add(line);
			}
		});
		return collection;
	}
214158
public static <T> File writeUtf8Lines(Collection<T> list, String path) throws IORuntimeException {
		return writeLines(list, path, CharsetUtil.CHARSET_UTF_8);
	}
979906
public static String readFileToString(File file, final Charset charset) throws IOException {
        String line = null;
        BufferedReader reader = getBufferReader(file, charset);
        StringBuffer strBuffer = new StringBuffer();

        while ((line = reader.readLine()) != null) {
            strBuffer.append(line);
        }
        return strBuffer.toString();
    }
585311
public static <T> File writeUtf8Lines(Collection<T> list, File file) throws IORuntimeException {
		return writeLines(list, file, CharsetUtil.CHARSET_UTF_8);
	}
1020977
public Toml read(File file) {
    try {
      return read(new InputStreamReader(new FileInputStream(file), "UTF8"));
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
108344
public static void stringToFile(String string, File file, String charsetName) {
		FileOutputStream fos = null;
		Writer writer = null;
		try {
			try {
				fos = new FileOutputStream(file);
				writer = new OutputStreamWriter(fos, charsetName);
				writer.write(string);
			} finally {
				if (writer != null) {
					writer.close();
				} else if (fos != null) {
					fos.close();
				}
			}
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
164731
public static <T extends Collection<String>> T readUtf8Lines(InputStream in, T collection) throws IORuntimeException {
		return readLines(in, CharsetUtil.CHARSET_UTF_8, collection);
	}
338872
public static String readString(File file, String charsetName) throws IORuntimeException {
		return readString(file, CharsetUtil.charset(charsetName));
	}
1234643
public static void append(File file, Object text, String charset) throws IOException {
        Writer writer = null;
        try {
            FileOutputStream out = new FileOutputStream(file, true);
            if (!file.exists()) {
                writeUTF16BomIfRequired(charset, out);
            }
            writer = new OutputStreamWriter(out, charset);
            InvokerHelper.write(writer, text);
            writer.flush();

            Writer temp = writer;
            writer = null;
            temp.close();
        } finally {
            closeWithWarning(writer);
        }
    }
110763
public static Function<File, Iterable<String>> toLinesFunction(final Charset charset) {
    return new Function<File, Iterable<String>>() {
      @Override
      public Iterable<String> apply(final File input) {
        try {
          return Files.readLines(input, charset);
        } catch (IOException e) {
          e.printStackTrace();
          throw new RuntimeException(e);
        }
      }
    };
  }
405859
@Override
	public String readStr(Charset charset) throws IORuntimeException{
		BufferedReader reader = null;
		try {
			reader = getReader(charset);
			return IoUtil.read(reader);
		} finally {
			IoUtil.close(reader);
		}
	}
293324
public static String readString(String path, String charsetName) throws IORuntimeException {
		return readString(file(path), charsetName);
	}
1326445
public static <T> File writeLines(Collection<T> list, File file, String charset) throws IORuntimeException {
		return writeLines(list, file, charset, false);
	}
395654
@Deprecated
	public static <T> T load(ReaderHandler<T> readerHandler, String path, String charset) throws IORuntimeException {
		return FileReader.create(file(path), CharsetUtil.charset(charset)).read(readerHandler);
	}
1000949
public static <T> File appendUtf8Lines(Collection<T> list, File file) throws IORuntimeException {
		return appendLines(list, file, CharsetUtil.CHARSET_UTF_8);
	}
1079730
public static <T> File appendLines(Collection<T> list, File file, String charset) throws IORuntimeException {
		return writeLines(list, file, charset, true);
	}