Here you can find the source of createZipInputStream(InputStream inStream, Charset charset)
static ZipInputStream createZipInputStream(InputStream inStream, Charset charset)
//package com.java2s; //License from project: Apache License import java.io.InputStream; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.nio.charset.Charset; import java.util.zip.ZipInputStream; public class Main { private static final String MISSING_METHOD_PLEASE_UPGRADE = "Your JRE doesn't support the ZipFile Charset constructor. Please upgrade JRE to 1.7 use this feature. Tried constructor ZipFile(File, Charset)."; private static final String CONSTRUCTOR_MESSAGE_FOR_INPUT = "Using constructor ZipInputStream(InputStream, Charset) has failed: "; /**/*from w w w. j a v a2s . c o m*/ * Returns a ZipInputStream opened with a given charset. */ static ZipInputStream createZipInputStream(InputStream inStream, Charset charset) { if (charset == null) return new ZipInputStream(inStream); try { Constructor<ZipInputStream> constructor = ZipInputStream.class .getConstructor(new Class[] { InputStream.class, Charset.class }); return (ZipInputStream) constructor.newInstance(new Object[] { inStream, charset }); } catch (NoSuchMethodException e) { throw new IllegalStateException(MISSING_METHOD_PLEASE_UPGRADE, e); } catch (InstantiationException e) { throw new IllegalStateException(CONSTRUCTOR_MESSAGE_FOR_INPUT + e.getMessage(), e); } catch (IllegalAccessException e) { throw new IllegalStateException(CONSTRUCTOR_MESSAGE_FOR_INPUT + e.getMessage(), e); } catch (IllegalArgumentException e) { throw new IllegalStateException(CONSTRUCTOR_MESSAGE_FOR_INPUT + e.getMessage(), e); } catch (InvocationTargetException e) { throw new IllegalStateException(CONSTRUCTOR_MESSAGE_FOR_INPUT + e.getMessage(), e); } } }