Java Dump Stream dumpFile(JarInputStream jin, File targetFile)

Here you can find the source of dumpFile(JarInputStream jin, File targetFile)

Description

Reads an entry from a JarInputStream and stores it in the given targetFile.

License

Open Source License

Parameter

Parameter Description
jin the input stream to read the file data from
targetFile the target file

Exception

Parameter Description
IOException thrown, if an error occurs

Declaration

private static final void dumpFile(JarInputStream jin, File targetFile) throws IOException 

Method Source Code


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

Related

  1. dump(PrintStream p, String indent, String s)
  2. dumparr(Object[] arr, PrintStream out, boolean term)
  3. dumpArray(PrintStream out, Object[] array)
  4. dumpEvent(String event, OutputStream stream)
  5. dumpFile(InputStream file, String header, String testName)
  6. dumpFile(String r_file, OutputStream outputstream)
  7. dumpInputOutputStream(InputStream is, OutputStream os)
  8. dumpInputStream(InputStream instream)
  9. dumpInputStream(InputStream is, PrintStream p)