Here you can find the source of copyStream(InputStream in, File dest)
public static void copyStream(InputStream in, File dest) throws IOException
//package com.java2s; /*//from www . j a va 2s .c om * Copyright (c) 2011, Marc R?ttig. * * This file is part of GenericKnimeNodes. * * GenericKnimeNodes is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ import java.io.BufferedInputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; public class Main { public static void copyStream(InputStream in, File dest) throws IOException { FileOutputStream out = new FileOutputStream(dest); BufferedInputStream bin = new BufferedInputStream(in); byte[] buffer = new byte[2048]; int len; while ((len = bin.read(buffer, 0, 2048)) != -1) { out.write(buffer, 0, len); } out.close(); bin.close(); } }