Returns an output stream corresponding to the given file.

@param file
a non-null {@code File} object.
@return
a {@code FileOutputStrea} to the given file, or {@code null} if the file
is not valid.
@throws FileNotFoundException
540774
public static OutputStream toFile(File file) throws FileNotFoundException {
		if(file != null) {
			return new FileOutputStream(file);
		}
		return null;
	}
855763
public static InputStream openFromFile(final File file) {
    try {
      InputStream is = new BufferedInputStream(new FileInputStream(file),
          BUFFER_SIZE);
      if (file.getName().endsWith(".gz") || file.getName().endsWith("gz")) {
        is = new GZIPInputStream(is, BUFFER_SIZE);
      }
      return is;
    } catch (final IOException e) {
      throw new TerminateToolException(-1,
          "File '" + file + "' cannot be found", e);
    }
  }
138826
public static boolean writeStream(File file, InputStream stream) throws IOException {
        return writeStream(file, stream, false);
    }
10976
@GwtIncompatible("Unnecessary")
  protected OutputStream filenameToOutputStream(String fileName) throws IOException {
    if (fileName == null){
      return null;
    }
    return new FileOutputStream(fileName);
  }
63376
public JavaFileObject asJavaFileObject(File file) {
        JavacFileManager fm = (JavacFileManager)context.get(JavaFileManager.class);
        return fm.getRegularFile(file);
    }
376164
public static OutputStream asOututStream(Path path) throws IOException {
		Validate.notNull(path, "path is null");
		return Files.newOutputStream(path);
	}
8810
public static InputStream fromFile(File file) throws FileNotFoundException {
		if(file != null && file.isFile() && file.canRead()) {
			return new FileInputStream(file);
		}
		return null;
	}
1150205
public static Object readObject(File file) throws IOException,
            ClassNotFoundException {
        FileInputStream fileIn = new FileInputStream(file);
        ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(fileIn));
        try {
            return in.readObject();
        } finally {
            IoUtils.safeClose(in);
        }
    }
1196044
public void generateOutput(String outputFileName) throws IOException {
        FileOutputStream stream = null;
        OutputStreamWriter writer = null;
        try {
            stream = new FileOutputStream(outputFileName);
            writer = new OutputStreamWriter(stream, charset);
            generateOutput(writer);
        } finally {
            if (writer != null) {
                writer.close();
            }
            if (stream != null) {
                stream.close();
            }
        }
    }
1197891
@Nullable
  public static FileOutputStream getOutputStream (@Nonnull final File aFile)
  {
    return getOutputStream (aFile, EAppend.DEFAULT);
  }
718917
public static Reader reader(File file) {
        E.illegalArgumentIfNot(file.canRead(), "file not readable: " + file.getPath());
        try {
            return new FileReader(file);
        } catch (IOException e) {
            throw E.ioException(e);
        }
    }
1130149
public void saveToFile(String outputFile) throws FileNotFoundException, IOException {
    Streams.copy(getInputStream(), new BufferedOutputStream(new FileOutputStream(outputFile)));
  }
1108605
public boolean endWrite(File file) {
        FileOutputStream fos = null;
        boolean endSuccess = false;
        try {
            fos = new FileOutputStream(file);
            endSuccess = this.endWrite(fos);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } finally {
            CommonUtils.closeIOStream(null, fos);
        }
        return endSuccess;
    }
203910
public static String readFile(File file) throws IOException {
        StringBuilder content = new StringBuilder();
        String line;
        try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
            while ((line = reader.readLine()) != null) {
                content.append(line).append("\r\n");
            }
        }
        return content.toString();
    }
738560
private S getInputStreamForFile(File file) throws IOException {
        assert file != null : "File must be specified";
        return this.getInputStreamForRawStream(new FileInputStream(file));
    }
1049579
protected OutputStream createFileOutputStream(File file) {
    try {
      return new FileOutputStream(file);
    } catch (FileNotFoundException e) {
      throw new GenException(Message.DOMAGEN9001, e, e);
    }
  }
540040
public static String readFile(File file) {
		FileInputStream inputStream;
		try {
			inputStream = new FileInputStream(file);
			return new String(readStream(inputStream));
		} catch (FileNotFoundException e) {
			JK.throww(e);
			return null;
		}
	}