Exports file in requested format

@param drive drive client
@param file file to be exported
@param format target format
@return exported data
@throws IOException thrown when exporting fails unexpectedly
321101
public static DownloadResponse exportFile(Drive drive, File file, String format) throws IOException {
	  return exportFile(drive, file.getId(), format);
	}
1148562
private OutputStream openFile(File file) throws BindException
  {
    try
    {
      return new GZIPOutputStream(new FileOutputStream(file));
    }
    catch (IOException ex)
    {
      throw new BindException(
          String.format("Failed to create output file %s: %s", file.toString(), ex.getMessage()), BindException.Type.SERIALIZATION);
    }
  }
525587
private static void doCopyFile(File srcFile, File destFile) throws IOException
   {
      if (destFile.exists() && destFile.isDirectory())
      {
         throw new IOException("Destination '" + destFile + "' exists but is a directory");
      }

      FileInputStream fis = null;
      FileOutputStream fos = null;
      FileChannel input = null;
      FileChannel output = null;
      try
      {
         fis = new FileInputStream(srcFile);
         fos = new FileOutputStream(destFile);
         input = fis.getChannel();
         output = fos.getChannel();
         long size = input.size();
         long pos = 0;
         long count = 0;
         while (pos < size)
         {
            count = (size - pos) > FIFTY_MB ? FIFTY_MB : (size - pos);
            pos += output.transferFrom(input, pos, count);
         }
      }
      finally
      {
         Streams.closeQuietly(output);
         Streams.closeQuietly(fos);
         Streams.closeQuietly(input);
         Streams.closeQuietly(fis);
      }

      if (srcFile.length() != destFile.length())
      {
         throw new IOException("Failed to copy full contents from '" +
                  srcFile + "' to '" + destFile + "'");
      }
   }
877135
public void exportScores(File file, String delimiter) throws IOException {
        try (FileOutputStream fos = new FileOutputStream(file)) {
            exportScores(fos, delimiter);
        }
    }
1306968
@Override
    public T fromFile(final File file) throws IllegalArgumentException, DescriptorImportException {
        // Precondition checks
        if (file == null) {
            throw new IllegalArgumentException("File not specified");
        }

        // Delegate
        try {
            return this.fromStream(new FileInputStream(file));
        } catch (final FileNotFoundException e) {
            throw new IllegalArgumentException("Specified file does not exist or is a directory: "
                + file.getAbsolutePath());
        }
    }
1096087
public void exportObjects2Excel(List<?> data, List<String> header, OutputStream os)
            throws IOException {

        try (Workbook workbook = exportExcelBySimpleHandler(data, header, null, true)) {
            workbook.write(os);
        }
    }
412357
public static void writeStringToFile(String path, String toWrite, JavaSparkContext sc) throws IOException {
        writeStringToFile(path, toWrite, sc.sc());
    }
1352447
public static byte[] readFileAtOnce(final File file) throws IOException {
		final FileInputStream fIn = new FileInputStream(file);
		return readFileAtOnce(fIn);
	}
464844
public static FileObject toFileObject(File file) {
        if (file == null) {
            return null;
        }
        try {
            return getFileSystemManager().toFileObject(file);
        } catch (FileSystemException e) {
            throw new IllegalStateException(e);
        }
    }
38940
public void writeToStream(final String format, final OutputStream outputStream) {
        try {
            LOGGER.debug("Writing WordCloud image data to output stream");
            ImageIO.write(bufferedImage, format, outputStream);
            LOGGER.debug("Done writing WordCloud image data to output stream");

        } catch (final IOException e) {
            LOGGER.error(e.getMessage(), e);
            throw new KumoException("Could not write wordcloud to outputstream due to an IOException", e);
        }
    }
493819
public void writeToFile(File file) {
        try {
            try (OutputStream os = new FileOutputStream(file)) {
                InputStreams.transferTo(body(), os);
            }
        } catch (IOException e) {
            throw new RequestsException(e);
        } finally {
            close();
        }
    }
1092782
public static void copy(File file, OutputStream out) throws IOException {
    FileInputStream in = new FileInputStream(file);
    try {
      IOUtils.copy(new BufferedInputStream(in), out);
    }
    finally {
      IOUtils.closeQuietly(in);
    }
  }
856684
public static int serialize(final File directory, String name, Object obj) {
        try (FileOutputStream stream = new FileOutputStream(new File(directory, name))) {
            return serialize(stream, obj);
        } catch (IOException e) {
            throw new ReportGenerationException(e);
        }
    }
961633
public void stringToFile(String content, File file) throws IOException {
        stringToOutputStream(content, new FileOutputStream(file));
    }
866824
public static void writeInPemFormat(final Key key, final @NonNull File file) throws IOException
	{
		StringWriter stringWriter = new StringWriter();
		JcaPEMWriter pemWriter = new JcaPEMWriter(stringWriter);
		pemWriter.writeObject(key);
		pemWriter.close();
		String pemFormat = stringWriter.toString();
		pemFormat = pemFormat.replaceAll("\\r\\n", "\\\n");
		WriteFileExtensions.string2File(file, pemFormat);
	}
459469
@SuppressWarnings("resource")
    public static byte[] readFile(File file) throws IOException {

        // create input and output stream
        FileInputStream in = new FileInputStream(file);

        // read the content
        return readFully(in, (int)file.length());
    }
1338192
public void save(File file) throws IOException {
        try (FileOutputStream out = new FileOutputStream(file)) {
            save(out);
        }
    }