Here you can find the source of dumpFile(JarInputStream jin, File targetFile)
Parameter | Description |
---|---|
jin | the input stream to read the file data from |
targetFile | the target file |
Parameter | Description |
---|---|
IOException | thrown, if an error occurs |
private static final void dumpFile(JarInputStream jin, File targetFile) throws IOException
//package com.java2s; /*/*from w w w .java 2 s . c o m*/ * Copyright 2012 PRODYNA AG * * Licensed under the Eclipse Public License (EPL), Version 1.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.opensource.org/licenses/eclipse-1.0.php or * http://www.nabucco.org/License.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 java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.util.jar.JarInputStream; public class Main { /** * Reads an entry from a JarInputStream and stores it in the given targetFile. * * @param jin * the input stream to read the file data from * @param targetFile * the target file * @throws IOException * thrown, if an error occurs */ private static final void dumpFile(JarInputStream jin, File targetFile) throws IOException { OutputStream out = new FileOutputStream(targetFile); byte[] buffer = new byte[1024]; int len = 0; while ((len = jin.read(buffer, 0, buffer.length)) != -1) { out.write(buffer, 0, len); } out.flush(); out.close(); } }