本文整理匯總了Java中java.util.jar.Pack200.newUnpacker方法的典型用法代碼示例。如果您正苦於以下問題:Java Pack200.newUnpacker方法的具體用法?Java Pack200.newUnpacker怎麽用?Java Pack200.newUnpacker使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.jar.Pack200
的用法示例。
在下文中一共展示了Pack200.newUnpacker方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: extractPack
import java.util.jar.Pack200; //導入方法依賴的package包/類
/**
* Extract Pack File
* @param in Input path to pack file
* @param out output path to resulting file
* @throws Exception if any errors occur
*/
protected void extractPack(String in, String out) throws Exception {
File f = new File(in);
FileOutputStream fostream = new FileOutputStream(out);
JarOutputStream jostream = new JarOutputStream(fostream);
try {
Pack200.Unpacker unpacker = Pack200.newUnpacker();
unpacker.unpack(f, jostream);
} finally {
jostream.close();
fostream.close();
}
// delete pack file as its no longer needed
f.delete();
}
示例2: run
import java.util.jar.Pack200; //導入方法依賴的package包/類
public void run() {
Unpacker unpack = Pack200.newUnpacker();
try {
long begin = System.currentTimeMillis();
StreamClassLoader streamClassLoader = new StreamClassLoader();
if ( inFile != null ) { unpack.unpack( inFile, streamClassLoader ); }
else { unpack.unpack( in, streamClassLoader ); }
streamClassLoader.close();
long unpackingTime = System.currentTimeMillis() - begin;
Class main = findClass( mainClass );
Method mainMethod = main.getMethod( "main", String[].class );
mainMethod.invoke( null, new Object[] { args } );
}
catch ( Exception e ) {
e.printStackTrace();
}
}
示例3: uncompressPackGz
import java.util.jar.Pack200; //導入方法依賴的package包/類
private void uncompressPackGz(URL compressedLocation, URL uncompressedLocation, Version version) throws IOException {
OutputController.getLogger().log(OutputController.Level.ERROR_DEBUG, "Extracting packgz: " + compressedLocation + " to " + uncompressedLocation);
try (GZIPInputStream gzInputStream = new GZIPInputStream(new FileInputStream(CacheUtil
.getCacheFile(compressedLocation, version)))) {
InputStream inputStream = new BufferedInputStream(gzInputStream);
JarOutputStream outputStream = new JarOutputStream(new FileOutputStream(CacheUtil
.getCacheFile(uncompressedLocation, version)));
Pack200.Unpacker unpacker = Pack200.newUnpacker();
unpacker.unpack(inputStream, outputStream);
outputStream.close();
inputStream.close();
}
}
示例4: copyLibraries
import java.util.jar.Pack200; //導入方法依賴的package包/類
private void copyLibraries(String library, ThreadProcessor processor) throws URISyntaxException, IOException {
String userdir = getUserdir(processor);
String libpath = userdir + "lib/" + library + "/";
File libfile = new File(libpath);
libfile.mkdirs();
String[] listfiles = getResourceListing(Osm2garmin.class, "org/mantlik/osm2garmin/" + library + "/");
for (String name : listfiles) {
InputStream stream = Osm2garmin.class.getResourceAsStream(library + "/" + name);
if (!name.equals("")) {
if (name.endsWith("pack.gz")) {
String jarname = name.replace("pack.gz", "jar");
InputStream input = new GZIPInputStream(stream);
Pack200.Unpacker unpacker = Pack200.newUnpacker();
JarOutputStream jo = new JarOutputStream(new FileOutputStream(libpath + jarname));
unpacker.unpack(input, jo);
jo.close();
} else {
copyFile(stream, new File(libpath + name));
}
}
}
}
示例5: pack2Jar
import java.util.jar.Pack200; //導入方法依賴的package包/類
public static void pack2Jar(InputStream is,OutputStream os, boolean closeIS, boolean closeOS) throws IOException {
Unpacker unpacker = Pack200.newUnpacker();
SortedMap<String, String> p = unpacker.properties();
p.put(Unpacker.DEFLATE_HINT, Unpacker.TRUE);
is=new GZIPInputStream(is);
JarOutputStream jos=null;
try{
jos = new JarOutputStream(os);
unpacker.unpack(is, jos);
jos.finish();
}
finally{
if(closeIS)Util.closeEL(is);
if(closeOS)Util.closeEL(jos);
}
}
示例6: pack2Jar
import java.util.jar.Pack200; //導入方法依賴的package包/類
public static void pack2Jar(InputStream is,OutputStream os, boolean closeIS, boolean closeOS) throws IOException {
Unpacker unpacker = Pack200.newUnpacker();
SortedMap<String, String> p = unpacker.properties();
p.put(Unpacker.DEFLATE_HINT, Unpacker.TRUE);
is=new GZIPInputStream(is);
JarOutputStream jos=null;
try{
jos = new JarOutputStream(os);
unpacker.unpack(is, jos);
jos.finish();
}
finally{
if(closeIS)IOUtil.closeEL(is);
if(closeOS)IOUtil.closeEL(jos);
}
}
示例7: unpackPacked200Jar
import java.util.jar.Pack200; //導入方法依賴的package包/類
/**
* Unpacks a pack200 packed jar file from {@code packedJar} into {@code target}. If {@code
* packedJar} has a {@code .gz} extension, it will be gunzipped first.
*/
public static void unpackPacked200Jar (File packedJar, File target) throws IOException
{
InputStream packedJarIn = null;
FileOutputStream extractedJarFileOut = null;
JarOutputStream jarOutputStream = null;
try {
extractedJarFileOut = new FileOutputStream(target);
jarOutputStream = new JarOutputStream(extractedJarFileOut);
packedJarIn = new FileInputStream(packedJar);
if (packedJar.getName().endsWith(".gz")) {
packedJarIn = new GZIPInputStream(packedJarIn);
}
Pack200.Unpacker unpacker = Pack200.newUnpacker();
unpacker.unpack(packedJarIn, jarOutputStream);
} finally {
StreamUtil.close(jarOutputStream);
StreamUtil.close(extractedJarFileOut);
StreamUtil.close(packedJarIn);
}
}
示例8: verify6991164
import java.util.jar.Pack200; //導入方法依賴的package包/類
static void verify6991164() {
Unpacker unpacker = Pack200.newUnpacker();
String versionStr = unpacker.toString();
String expected = "Pack200, Vendor: " +
System.getProperty("java.vendor") + ", Version: " +
JAVA7_PACKAGE_MAJOR_VERSION + "." + JAVA7_PACKAGE_MINOR_VERSION;
if (!versionStr.equals(expected)) {
System.out.println("Expected: " + expected);
System.out.println("Obtained: " + versionStr);
throw new RuntimeException("did not get expected string " + expected);
}
}
示例9: unpack0
import java.util.jar.Pack200; //導入方法依賴的package包/類
private static void unpack0(File inFile, JarOutputStream jarStream,
boolean useJavaUnpack) throws IOException {
// Unpack the files
Pack200.Unpacker unpacker = Pack200.newUnpacker();
Map<String, String> props = unpacker.properties();
if (useJavaUnpack) {
props.put("com.sun.java.util.jar.pack.disable.native", "true");
}
// Call the unpacker
unpacker.unpack(inFile, jarStream);
}
示例10: unpack
import java.util.jar.Pack200; //導入方法依賴的package包/類
@Override
public void unpack( File source, File destination, Map<String, String> props )
throws IOException
{
InputStream in = null;
JarOutputStream out = null;
try
{
in = new FileInputStream( source );
if ( isGzipped( source ) )
{
in = new GZIPInputStream( in );
}
in = new BufferedInputStream( in );
out = new JarOutputStream( new BufferedOutputStream( new FileOutputStream( destination ) ) );
Pack200.Unpacker unpacker = Pack200.newUnpacker();
unpacker.properties().putAll( props );
unpacker.unpack( in, out );
}
finally
{
IOUtil.close( in );
IOUtil.close( out );
}
}
示例11: verify6991164
import java.util.jar.Pack200; //導入方法依賴的package包/類
static void verify6991164() {
Unpacker unpacker = Pack200.newUnpacker();
String versionStr = unpacker.toString();
String expected = "Pack200, Vendor: " +
System.getProperty("java.vendor") + ", Version: " +
JAVA6_PACKAGE_MAJOR_VERSION + "." + JAVA6_PACKAGE_MINOR_VERSION;
if (!versionStr.equals(expected)) {
System.out.println("Expected: " + expected);
System.out.println("Obtained: " + versionStr);
throw new RuntimeException("did not get expected string " + expected);
}
}
示例12: unpack200
import java.util.jar.Pack200; //導入方法依賴的package包/類
public static Application unpack200(File file) throws IOException {
logger.info("Unpacking pack200 file " + file + "...");
/* read the .pack200 file into memory and tack on the GZIP header */
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
out.write(31);
out.write(-117);
try (InputStream is = new FileInputStream(file)) {
for (;;) {
byte[] buf = new byte[4096];
int len = is.read(buf);
if (len == -1)
break;
out.write(buf, 0, len);
}
}
} finally {
out.close();
}
/* convert the pack200 file to a temporary jar file */
File tmp = File.createTempFile("tmp", ".jar");
JarOutputStream os = new JarOutputStream(new FileOutputStream(tmp));
try {
InputStream in = new GZIPInputStream(new ByteArrayInputStream(out.toByteArray()));
try {
Pack200.Unpacker unpacker = Pack200.newUnpacker();
unpacker.unpack(in, os);
} finally {
in.close();
}
} finally {
os.close();
}
/* unpack the temporary jar file */
return unpackJar(tmp);
}
示例13: normalize
import java.util.jar.Pack200; //導入方法依賴的package包/類
public static void normalize(File from, File to, Map<String, String> props) throws IOException {
if (props == null) {
props = new HashMap();
}
((Map) props).put("pack.segment.limit", "-1");
File f = File.createTempFile("commons-compress", "pack200normalize");
f.deleteOnExit();
try {
Object os = new FileOutputStream(f);
Object j = null;
try {
Pack200.Packer p = Pack200.newPacker();
p.properties().putAll((Map) props);
p.pack(new JarFile(from), (OutputStream) os);
j = null;
((OutputStream) os).close();
os = null;
Pack200.Unpacker u = Pack200.newUnpacker();
os = new JarOutputStream(new FileOutputStream(to));
u.unpack(f, (JarOutputStream) os);
} finally {
if (j != null) {
((JarFile) j).close();
}
if (os != null) {
((OutputStream) os).close();
}
}
} finally {
f.delete();
}
}
示例14: getPack200Unpacker
import java.util.jar.Pack200; //導入方法依賴的package包/類
private Pack200.Unpacker getPack200Unpacker()
{
if (unpacker == null)
{
unpacker = Pack200.newUnpacker();
}
return unpacker;
}
示例15: unpack200
import java.util.jar.Pack200; //導入方法依賴的package包/類
private static void unpack200(final File compressedInput, final File decompressedOutput)
throws FileNotFoundException, IOException {
if (compressedInput == null) {
throw new NullPointerException("compressedInput");
}
if (decompressedOutput == null) {
throw new NullPointerException("decompressedOutput");
}
try (final FileOutputStream fostream = new FileOutputStream(decompressedOutput)) {
try (final JarOutputStream jostream = new JarOutputStream(fostream)) {
final Pack200.Unpacker unpacker = Pack200.newUnpacker();
unpacker.unpack(compressedInput, jostream);
}
}
}