Here you can find the source of writeFile(OutputStream os, File f)
public static void writeFile(OutputStream os, File f) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class Main { private static final int DEFAULT_BUFFER_SIZE = 8192; public static void writeFile(OutputStream os, File f) throws IOException { try (InputStream fis = new FileInputStream(f)) { writeFile(os, fis);//from www . j a v a 2 s. com } } public static void writeFile(OutputStream os, InputStream is) throws IOException { byte[] buffer = new byte[DEFAULT_BUFFER_SIZE]; int bytesRead; while ((bytesRead = is.read(buffer)) != -1) { os.write(buffer, 0, bytesRead); } os.flush(); } }