Here you can find the source of copyStream(InputStream in, FileOutputStream out, IProgressMonitor monitor, int length)
private static void copyStream(InputStream in, FileOutputStream out, IProgressMonitor monitor, int length) throws IOException
//package com.java2s; /*/* w w w .j a va 2 s . c om*/ * Copyright (c) 2014, the Dart project authors. * * Licensed under the Eclipse Public License v1.0 (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at * * http://www.eclipse.org/legal/epl-v10.html * * Unless required by applicable law or agreed to in writing, software distributed under the License * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express * or implied. See the License for the specific language governing permissions and limitations under * the License. */ import org.eclipse.core.runtime.IProgressMonitor; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; public class Main { private static void copyStream(InputStream in, FileOutputStream out, IProgressMonitor monitor, int length) throws IOException { byte[] data = new byte[4096]; int count = in.read(data); while (count != -1) { out.write(data, 0, count); if (length != -1) { monitor.worked(count); } count = in.read(data); } in.close(); out.close(); } }