Obtain the OutputStream for the given file.

@param keyFile
@return
@throws IOException
426924
private OutputStream getOutputStream(final String keyFile) throws IOException {
        try {
            return AccessController.doPrivileged(new PrivilegedExceptionAction<OutputStream>() {
                @Override
                public OutputStream run() throws IOException {
                    return new FileOutputStream(new File(keyFile));
                }
            });
        } catch (PrivilegedActionException e) {
            // Wrap the wrapped IOException from doPriv in an IOException and re-throw
            throw new IOException(e.getCause());
        }
    }
1197891
@Nullable
  public static FileOutputStream getOutputStream (@Nonnull final File aFile)
  {
    return getOutputStream (aFile, EAppend.DEFAULT);
  }
1271732
public T mkfile() throws MkfileException {
        try {
            if (exists()) {
                throw new MkfileException(this);
            }
            return writeBytes();
        } catch (IOException e) {
            throw new MkfileException(this, e);
        }
    }
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;
    }
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;
  }
39873
public InputStreamReader getFileStream(File file, String encoding)
			throws NoSuchPathException, UnmarshalException{
		try {
			return new InputStreamReader(new FileInputStream(file), encoding);
		} catch (FileNotFoundException e) {
			throw new NoSuchPathException(e);
		} catch (UnsupportedEncodingException e){
			throw new UnmarshalException(e);
		}
	}
350424
public void writeFile(File inputFile, String jarPath) throws IOException {

		// Get an input stream on the file.
		FileInputStream fis = new FileInputStream(inputFile);
		try {
			// create the zip entry
			JarEntry entry = new JarEntry(jarPath);
			entry.setTime(inputFile.lastModified());
			writeEntry(fis, entry);

		} finally {
			// close the file stream used to read the file
			fis.close();
		}
	}
697147
@Nullable
  public static FileOutputStream getOutputStream (@Nonnull final File aFile, @Nonnull final EAppend eAppend)
  {
    ValueEnforcer.notNull (aFile, "File");
    ValueEnforcer.notNull (eAppend, "Append");

    if (internalCheckParentDirectoryExistanceAndAccess (aFile).isInvalid ())
      return null;

    // OK, parent is present and writable
    try
    {
      return new CountingFileOutputStream (aFile, eAppend);
    }
    catch (final FileNotFoundException ex)
    {
      if (LOGGER.isWarnEnabled ())
        LOGGER.warn ("Failed to create output stream for '" +
                     aFile +
                     "'; append: " +
                     eAppend +
                     ": " +
                     ex.getClass ().getName () +
                     " - " +
                     ex.getMessage ());
      return null;
    }
  }
953746
private FileChannel getChannel(final boolean append) throws IOException {

		if (this.privateFileChannel == null) {

			java.io.File fileOnDisk = file.getFileOnDisk();

			fileOnDisk.getParentFile().mkdirs();

			this.privateFileChannel = new FileOutputStream(fileOnDisk, append).getChannel();
		}

		return this.privateFileChannel;
	}
1205773
public  InputStream getInputStream(File f)
	throws IOException
	{

		// use the magic numbers to determine the compression type,
		// use file extension only as 2nd choice

		int magic = 0;


		InputStream test = getInputStreamFromFile(f);
		magic = getMagicNumber(test);
		test.close();


		InputStream inputStream = null;

		String fileName = f.getName();

		if (magic == UncompressInputStream.LZW_MAGIC ) {
			// a Z compressed file
			return openCompressedFile(f);
		}

		else if (magic == GZIP_MAGIC ) {
			return openGZIPFile(f);
		}

		else if ( fileName.endsWith(".gz")) {
			return openGZIPFile(f);
		}

		else if ( fileName.endsWith(".zip")){

			ZipFile zipfile = new ZipFile(f);

			// stream to first entry is returned ...
			ZipEntry entry;
			Enumeration<? extends ZipEntry> e = zipfile.entries();
			if ( e.hasMoreElements()){
				entry = e.nextElement();
				inputStream = zipfile.getInputStream(entry);
			} else {
				throw new IOException ("Zip file has no entries");
			}

		}

		else if ( fileName.endsWith(".jar")) {

			JarFile jarFile = new JarFile(f);

			// stream to first entry is returned
			JarEntry entry;
			Enumeration<JarEntry> e = jarFile.entries();
			if ( e.hasMoreElements()){
				entry = e.nextElement();
				inputStream = jarFile.getInputStream(entry);
			} else {
				throw new IOException ("Jar file has no entries");
			}
		}

		else if ( fileName.endsWith(".Z")) {
			// unix compressed
			return openCompressedFile(f);

		}

		else {

			// no particular extension found, assume that it is an uncompressed file
			inputStream = getInputStreamFromFile(f);
		}

		return inputStream;
	}
252326
private InputStream getInputStreamFromFile(File f) throws FileNotFoundException{
		InputStream stream = null;



		if ( cacheRawFiles ){
			stream = FlatFileCache.getInputStream(f.getAbsolutePath());

			if ( stream == null){
				FlatFileCache.addToCache(f.getAbsolutePath(),f);
				stream = FlatFileCache.getInputStream(f.getAbsolutePath());
			}
		}

		if ( stream == null)
			stream = new FileInputStream(f);

		return stream;
	}
825831
public static void convertFile(File keyFile, int toFormat, File toFile)
			throws IOException {

		SshPublicKeyFile pub = parse(new FileInputStream(keyFile));
		createFile(pub.toPublicKey(), pub.getComment(), toFormat, toFile);
	}
459820
private static InputStream inputStreamFromFile(URL resourceUrl)
      throws IOException, URISyntaxException {
    File resourceFile = new File(resourceUrl.toURI());
    return new FileInputStream(resourceFile);
  }
390997
public static InputStream asInputStream(File file) throws IOException {
		Validate.notNull(file, "file is null");
		return asInputStream(file.toPath());
	}
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);
        }
    }
386757
public InputStreamReader getFileStream(String filename)
			throws NoSuchPathException{
		try {
			return new InputStreamReader(new FileInputStream(filename));
		} catch (FileNotFoundException e) {
			throw new NoSuchPathException(e);
		}
	}
437943
public InputStream getInputStream()
    throws IOException
  {
    if (_is == null)
      _is = new FileInputStream(_file.getFD());

    return _is;
  }