code: public static void copyFile(InputStream _inputStream, String newFile) throws IOException {
          try (InputStream inputStream = _inputStream;
               FileOutputStream outputStream = new FileOutputStream(newFile)) {
              int length = 2097152;
              byte[] buffer = new byte[length];
              while (true) {
                  int read = inputStream.read(buffer);
                  if (read == -1) {
                      outputStream.flush();
                      break;
                  } else {
                      outputStream.write(buffer, 0, read);
                  }
              }
          }
      }
docs: 拷贝文件，本方法会将输入输出流关闭。