Example #1
0
 /**
  * 将一个字节数组写入一个输出流。
  *
  * <p><b style=color:red>注意</b>,它会关闭输出流
  *
  * @param ops 输出流
  * @param bytes 字节数组
  */
 public static void writeAndClose(OutputStream ops, byte[] bytes) {
   try {
     write(ops, bytes);
   } catch (IOException e) {
     throw Lang.wrapThrow(e);
   } finally {
     safeClose(ops);
   }
 }
Example #2
0
 /**
  * 将一段文本全部写入一个writer。
  *
  * <p><b style=color:red>注意</b>,它会关闭输出流
  *
  * @param writer 输出流
  * @param cs 文本
  */
 public static void writeAndClose(Writer writer, CharSequence cs) {
   try {
     write(writer, cs);
   } catch (IOException e) {
     throw Lang.wrapThrow(e);
   } finally {
     safeClose(writer);
   }
 }
Example #3
0
 /**
  * 将文本输入流写入一个文本输出流。块大小为 8192
  *
  * <p><b style=color:red>注意</b>,它会关闭输入/出流
  *
  * @param writer 输出流
  * @param reader 输入流
  */
 public static void writeAndClose(Writer writer, Reader reader) {
   try {
     write(writer, reader);
   } catch (IOException e) {
     throw Lang.wrapThrow(e);
   } finally {
     safeClose(writer);
     safeClose(reader);
   }
 }