Java FileWriter Write saveInputStreamInFile(InputStream stream, FileWriter f)

Here you can find the source of saveInputStreamInFile(InputStream stream, FileWriter f)

Description

save Input Stream In File

License

Open Source License

Declaration

public static void saveInputStreamInFile(InputStream stream, FileWriter f) throws IOException 

Method Source Code

//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();
        }
    }
}

Related

  1. saveFiles(final List contents, final File outputDirectory, final String outputName, final String fileExtension)
  2. saveFlows(Map differences, String file)
  3. saveFormedClustersToFile(Vector names, Collection> clusters, String filename)
  4. saveGraph(List> graph, String sFileName)
  5. saveIndex(File root_, Hashtable index)
  6. saveIntegerNodes2File(Integer[] nodes, String fileName)
  7. saveIntNodes2File(int[] nodes, String fileName)
  8. saveList(String listName, Set list)
  9. saveListStringToFile(String filePath, List listString)