Here you can find the source of writeStreamToFile(InputStream is, File out)
InputStream
to a file.
Parameter | Description |
---|---|
is | a parameter |
out | a parameter |
@SuppressWarnings("unused") public static void writeStreamToFile(InputStream is, File out)
//package com.java2s; /**//from w ww . ja va 2 s .c o m BlackBoard BreadBoard Designer Written and maintained by Matthias Pueski Copyright (c) 2010-2011 Matthias Pueski This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; public class Main { /** * Writes a given <code>InputStream</code> to a file. * * @param is * @param out */ @SuppressWarnings("unused") public static void writeStreamToFile(InputStream is, File out) { byte[] b; try { FileOutputStream fos = new FileOutputStream(out); b = new byte[is.available()]; for (int n; (n = is.read(b)) != -1;) { fos.write(b); } fos.close(); } catch (IOException e) { e.printStackTrace(); } } }