Here you can find the source of saveInputStreamInFile(InputStream stream, FileWriter f)
public static void saveInputStreamInFile(InputStream stream, FileWriter f) throws IOException
//package com.java2s; /*/*from w ww .j ava 2 s . co m*/ * Copyright 2010 * IBB-CEB - Institute for Biotechnology and Bioengineering - Centre of Biological Engineering * CCTC - Computer Science and Technology Center * * University of Minho * * This is free software: you can redistribute it and/or modify * it under the terms of the GNU Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This code is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Public License for more details. * * You should have received a copy of the GNU Public License * along with this code. If not, see http://www.gnu.org/licenses/ * * Created inside the SysBioPseg Research Group (http://sysbio.di.uminho.pt) */ import java.io.BufferedReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; public class Main { public static void saveInputStreamInFile(InputStream stream, FileWriter f) throws IOException { InputStreamReader st = new InputStreamReader(stream); BufferedReader br = new BufferedReader(st); String line; try { while ((line = br.readLine()) != null) f.append(line + "\n"); } finally { st.close(); br.close(); } } }