Encode the given input wav file to an output file.

@param inputFile Input wav file to encode.
@param outputFile Output file to write FLAC stream to. If file exists, it
will be overwritten without prompting.

@return Status flag for encode
970715
public Status encode(File inputFile, File outputFile) {
    Status status = Status.FULL_ENCODE;
    this.outFile = outputFile;
    //take file and initial configuration.
    //open file
    AudioInputStream sin = null;
    AudioFormat format = null;
    try {
      sin = AudioSystem.getAudioInputStream(inputFile);
    }catch(IOException e) {
      status = Status.FILE_IO_ERROR;
    }catch (UnsupportedAudioFileException e) {
      status = Status.UNSUPPORTED_FILE;
    }finally {
      if(status != Status.FULL_ENCODE)
      {
        try {
          sin.close();
        }catch (IOException e) {
          //Nothing to do, close failed
        }
        return status;
      }
    }
    try {
      format = sin.getFormat();
      //sanitize and optimize configurations
      adjustConfigurations(format);
      //open stream
      openStream();
      AudioStreamEncoder.encodeAudioInputStream(sin, MAX_READ, flac, useThreads);
    }
    catch(IOException e) {
      status = Status.FILE_IO_ERROR;
    }
    catch(IllegalArgumentException e) {
      status = Status.GENERAL_ERROR;
      String message = e.getMessage();
      if(message.equals(Status.UNSUPPORTED_SAMPLE_SIZE.name()))
        status = Status.UNSUPPORTED_SAMPLE_SIZE;
      else
        throw e;
    }
    finally {
      try {
        sin.close();
      }catch (IOException e) {
        //Nothing to do, close failed
      }
    }
    
    return status;
  }
795913
public void toFileWithoutExtension(Path outputFile) {
        Validate.notNull(outputFile, "outputFile must not be null");

        applyOverviewDocument().writeToFileWithoutExtension(outputFile, StandardCharsets.UTF_8);
        applyPathsDocument().writeToFileWithoutExtension(outputFile, StandardCharsets.UTF_8, StandardOpenOption.APPEND);
        applyDefinitionsDocument().writeToFileWithoutExtension(outputFile, StandardCharsets.UTF_8, StandardOpenOption.APPEND);
        applySecurityDocument().writeToFileWithoutExtension(outputFile, StandardCharsets.UTF_8, StandardOpenOption.APPEND);
    }
547082
public static FileUtils.FileCopyResult gunzip(InputStream in, File outFile) throws IOException
  {
    try (GZIPInputStream gzipInputStream = gzipInputStream(in)) {
      NativeIO.chunkedCopy(gzipInputStream, outFile);
      return new FileUtils.FileCopyResult(outFile);
    }
  }
1197891
@Nullable
  public static FileOutputStream getOutputStream (@Nonnull final File aFile)
  {
    return getOutputStream (aFile, EAppend.DEFAULT);
  }
970953
public static boolean write(File pFile, byte[] pData) throws IOException {
        boolean success = false;
        OutputStream out = null;

        try {
            out = new BufferedOutputStream(new FileOutputStream(pFile));
            success = write(out, pData);
        }
        finally {
            close(out);
        }
        return success;
    }
1082972
@Override
  protected String[] prepareResponseFile(final File outputFile, final String[] args) throws IOException {
    final String cmdargs[] = BorlandProcessor.prepareResponseFile(outputFile, args, " + \n");
    cmdargs[cmdargs.length - 1] = getCommandFileSwitch(cmdargs[cmdargs.length - 1]);
    return cmdargs;
  }
3647
public void save(String modelFile) throws IOException
    {
        DataOutputStream out = new DataOutputStream(new BufferedOutputStream(IOUtil.newOutputStream(modelFile)));
        save(out);
        out.close();
    }
813672
public SendAudio setAudio(File file) {
        Objects.requireNonNull(file, "file cannot be null!");
        this.audio = new InputFile(file, file.getName());
        return this;
    }
1186346
@Override
  public int write(AudioInputStream stream, Type fileType, File out) throws IOException {

    // Check, if writing is supported
    if (!flacTypes[0].equals(fileType)) {
      throw new IllegalArgumentException("File type " + fileType + " not supported.");
    }
    else if(AudioStreamEncoder.getDataFormatSupport(stream.getFormat()) != AudioStreamEncoder.SUPPORTED  ) {
       throw new IllegalArgumentException("Data Format not supported");
    }
    
    FLACFileOutputStream flacFileOutputStream = null;
    int bytesWritten = 0;
    try {
      flacFileOutputStream = new FLACFileOutputStream(out);
      AudioFormat format = stream.getFormat();

      // Sanitize and optimize configurations
      StreamConfiguration streamConfiguration = adjustConfigurations(format);
      EncodingConfiguration encodingConfiguration = new EncodingConfiguration();
      FLACEncoder flac = new FLACEncoder();
      if (!flac.setStreamConfiguration(streamConfiguration) ||
              !flac.setEncodingConfiguration(encodingConfiguration)) {
        throw new IOException("FLAC encoder initialization failed.");
      }

      flac.setOutputStream(flacFileOutputStream);
      flac.openFLACStream();

      AudioStreamEncoder.encodeAudioInputStream(stream, MAX_READ, flac, false);
      
    } finally {
      if (flacFileOutputStream != null) {
        bytesWritten = Long.valueOf(flacFileOutputStream.size()).intValue();
        flacFileOutputStream.close();
      }
    }

    return bytesWritten;
  }
756812
public static void copyFile(File srcFile, File destFile) throws IOException
    {
        InputStream reader = new FileInputStream(srcFile);
        OutputStream out = new FileOutputStream(destFile);
        try
        {
            byte[] buffer = new byte[2048];
            int n = 0;
            while (-1 != (n = reader.read(buffer))) 
            {
                out.write(buffer, 0, n);
            } 
        }
        finally
        {
            org.apache.commons.io.IOUtils.closeQuietly(out);
            org.apache.commons.io.IOUtils.closeQuietly(reader);
        }
    }
751076
protected String[] prepareResponseFile(final File outputFile, final String[] args) throws IOException {
    final String baseName = outputFile.getName();
    final File commandFile = new File(outputFile.getParent(), baseName + ".rsp");
    final FileWriter writer = new FileWriter(commandFile);
    int execArgCount = 1;
    if (this.isLibtool) {
      execArgCount++;
    }
    final String[] execArgs = new String[execArgCount + 1];
    System.arraycopy(args, 0, execArgs, 0, execArgCount);
    execArgs[execArgCount] = getCommandFileSwitch(commandFile.toString());
    for (int i = execArgCount; i < args.length; i++) {
      //
      // if embedded space and not quoted then
      // quote argument
      if (args[i].contains(" ") && args[i].charAt(0) != '\"') {
        writer.write('\"');
        writer.write(args[i]);
        writer.write("\"\n");
      } else {
        writer.write(args[i]);
        writer.write('\n');
      }
    }
    writer.close();
    return execArgs;
  }
108196
public final String transform(CharSequence content, File inputFile) {
		return transform(content, inputFile, true);
	}
90849
private void openOutputFile(final String outputFileName) throws IOException
	{
		myOutputFile = new File(outputFileName);
		myOutputStream = new FileOutputStream(myOutputFile);
		myStreamWriter = new OutputStreamWriter(myOutputStream, getOutputEncodingCode());
		myBufferedWriter = new BufferedWriter(myStreamWriter);
	}
342594
public static void copy(File sourceFile, File targetFile) throws IOException {
	FileInputStream in = new FileInputStream(sourceFile);
	try {
	    FileOutputStream out = new FileOutputStream(targetFile);
	    try {
		copy(in, out);
	    } finally {
		out.close();
	    }
	} finally {
	    in.close();
	}
    }
931367
public final String transform(Reader reader, File inputFile) {
		return transform(reader, inputFile, true);
	}
109924
public OutputStream getOutputStream(String remotefile)
			throws SftpStatusException, SshException {

		String remotePath = resolveRemotePath(remotefile);
		return new SftpFileOutputStream(sftp.openFile(remotePath,
				SftpSubsystemChannel.OPEN_CREATE
						| SftpSubsystemChannel.OPEN_TRUNCATE
						| SftpSubsystemChannel.OPEN_WRITE));

	}
636485
public static void decodeFileToFile (@Nonnull final String aInFile, @Nonnull final File aOutFile) throws IOException
  {
    final byte [] decoded = decodeFromFile (aInFile);
    try (final OutputStream out = FileHelper.getBufferedOutputStream (aOutFile))
    {
      out.write (decoded);
    }
  }