Java tutorial
//package com.java2s; //License from project: Apache License import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; public class Main { public static void writeFile(String filepath, InputStream is) throws IOException { File file = new File(filepath); BufferedWriter bw = new BufferedWriter(new FileWriter(file)); BufferedReader br = new BufferedReader(new InputStreamReader(is)); String line; while ((line = br.readLine()) != null) { bw.write(line + "\n"); } bw.close(); br.close(); } }