Java tutorial
//package com.java2s; import java.io.BufferedReader; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; public class Main { public static boolean addFile(InputStream src, File dest) { try { FileOutputStream out = new FileOutputStream(dest); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(src)); String line; while ((line = bufferedReader.readLine()) != null) { out.write((line + "\n").getBytes()); } out.close(); bufferedReader.close(); return true; } catch (IOException e) { } return false; } }