参考:spring内置工具类

FileCopyUtils文件、资源、IO 流

  1. // 从文件中读入到字节数组中
  2. byte[] copyToByteArray(File in)
  3. // 从输入流中读入到字节数组中
  4. byte[] copyToByteArray(InputStream in)
  5. // 从输入流中读入到字符串中
  6. String copyToString(Reader in)
  1. // 从字节数组到文件
  2. void copy(byte[] in, File out)
  3. // 从文件到文件
  4. int copy(File in, File out)
  5. // 从字节数组到输出流
  6. void copy(byte[] in, OutputStream out)
  7. // 从输入流到输出流
  8. int copy(InputStream in, OutputStream out)
  9. // 从输入流到输出流
  10. int copy(Reader in, Writer out)
  11. // 从字符串到输出流
  12. void copy(String in, Writer out)