Here you can find the source of writeStreamToFile(InputStream _actual, File _file)
public static void writeStreamToFile(InputStream _actual, File _file) throws FileNotFoundException, IOException
//package com.java2s; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class Main { public static void writeStreamToFile(InputStream _actual, File _file) throws FileNotFoundException, IOException { final OutputStream expected = new BufferedOutputStream(new FileOutputStream(_file)); try {//from www .j a v a2 s.c o m int red; while ((red = _actual.read()) >= 0) expected.write(red); } finally { expected.close(); } } }