本文整理汇总了Java中org.apache.harmony.unpack200.Archive类的典型用法代码示例。如果您正苦于以下问题:Java Archive类的具体用法?Java Archive怎么用?Java Archive使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Archive类属于org.apache.harmony.unpack200包,在下文中一共展示了Archive类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRemovePackFile
import org.apache.harmony.unpack200.Archive; //导入依赖的package包/类
public void testRemovePackFile() throws Exception {
File original = new File(Archive.class.getResource(
"/org/apache/harmony/pack200/tests/sql.pack.gz").toURI());
File copy = File.createTempFile("sqlcopy", ".pack.gz");
BufferedInputStream inputStream = new BufferedInputStream(
new FileInputStream(original));
BufferedOutputStream outputStream = new BufferedOutputStream(
new FileOutputStream(copy));
byte[] bytes = new byte[256];
int read = inputStream.read(bytes);
while (read > 0) {
outputStream.write(bytes, 0, read);
read = inputStream.read(bytes);
}
inputStream.close();
outputStream.close();
String inputFile = copy.getPath();
file = File.createTempFile("sqlout", ".jar");
file.deleteOnExit();
String outputFile = file.getPath();
Archive archive = new Archive(inputFile, outputFile);
archive.setRemovePackFile(true);
archive.unpack();
assertFalse(copy.exists());
}
示例2: testJustResourcesGZip
import org.apache.harmony.unpack200.Archive; //导入依赖的package包/类
public void testJustResourcesGZip() throws Exception {
in = Archive.class
.getResourceAsStream("/org/apache/harmony/pack200/tests/JustResources.pack.gz");
file = File.createTempFile("Just", "ResourcesGz.jar");
out = new JarOutputStream(new FileOutputStream(file));
Archive archive = new Archive(in, out);
archive.unpack();
}
示例3: testWithSqlE1
import org.apache.harmony.unpack200.Archive; //导入依赖的package包/类
public void testWithSqlE1() throws Exception {
in = Archive.class
.getResourceAsStream("/org/apache/harmony/pack200/tests/sql-e1.pack.gz");
file = File.createTempFile("sql-e1", ".jar");
out = new JarOutputStream(new FileOutputStream(file));
Archive archive = new Archive(in, out);
archive.unpack();
}
示例4: testWithPack200E1
import org.apache.harmony.unpack200.Archive; //导入依赖的package包/类
public void testWithPack200E1() throws Exception {
in = Archive.class
.getResourceAsStream("/org/apache/harmony/pack200/tests/pack200-e1.pack.gz");
file = File.createTempFile("p200-e1", ".jar");
out = new JarOutputStream(new FileOutputStream(file));
Archive archive = new Archive(in, out);
archive.unpack();
}
示例5: testWithPack200
import org.apache.harmony.unpack200.Archive; //导入依赖的package包/类
public void testWithPack200() throws Exception {
in = Archive.class
.getResourceAsStream("/org/apache/harmony/pack200/tests/pack200.pack.gz");
file = File.createTempFile("p200", ".jar");
out = new JarOutputStream(new FileOutputStream(file));
Archive archive = new Archive(in, out);
archive.unpack();
}
示例6: testWithJNDIE1
import org.apache.harmony.unpack200.Archive; //导入依赖的package包/类
public void testWithJNDIE1() throws Exception {
in = Archive.class
.getResourceAsStream("/org/apache/harmony/pack200/tests/jndi-e1.pack.gz");
file = File.createTempFile("jndi-e1", ".jar");
out = new JarOutputStream(new FileOutputStream(file));
Archive archive = new Archive(in, out);
archive.unpack();
}
示例7: testWithAnnotations
import org.apache.harmony.unpack200.Archive; //导入依赖的package包/类
public void testWithAnnotations() throws Exception {
in = Archive.class
.getResourceAsStream("/org/apache/harmony/pack200/tests/annotations.pack.gz");
file = File.createTempFile("annotations", ".jar");
out = new JarOutputStream(new FileOutputStream(file));
Archive archive = new Archive(in, out);
archive.unpack();
}
示例8: testWithE0
import org.apache.harmony.unpack200.Archive; //导入依赖的package包/类
public void testWithE0() throws Exception {
in = Archive.class
.getResourceAsStream("/org/apache/harmony/pack200/tests/simple-E0.pack.gz");
file = File.createTempFile("simple-e0", ".jar");
out = new JarOutputStream(new FileOutputStream(file));
Archive archive = new Archive(in, out);
archive.unpack();
}
示例9: testWithLargeClass
import org.apache.harmony.unpack200.Archive; //导入依赖的package包/类
public void testWithLargeClass() throws Exception {
in = Archive.class
.getResourceAsStream("/org/apache/harmony/pack200/tests/LargeClass.pack.gz");
file = File.createTempFile("largeClass", ".jar");
out = new JarOutputStream(new FileOutputStream(file));
Archive archive = new Archive(in, out);
archive.unpack();
}
示例10: testAlternativeConstructor
import org.apache.harmony.unpack200.Archive; //导入依赖的package包/类
public void testAlternativeConstructor() throws Exception {
String inputFile = new File(Archive.class
.getResource("/org/apache/harmony/pack200/tests/sql.pack.gz").toURI()).getPath();
file = File.createTempFile("sql", ".jar");
file.deleteOnExit();
String outputFile = file.getPath();
Archive archive = new Archive(inputFile, outputFile);
archive.unpack();
}
示例11: testWithLargeClass
import org.apache.harmony.unpack200.Archive; //导入依赖的package包/类
public void testWithLargeClass() throws Exception {
in = Archive.class
.getResourceAsStream("/org/apache/harmony/pack200/tests/LargeClass.pack.gz");
file = File.createTempFile("largeClass", ".jar");
file.deleteOnExit();
out = new JarOutputStream(new FileOutputStream(file));
Archive archive = new Archive(in, out);
archive.unpack();
}
示例12: main
import org.apache.harmony.unpack200.Archive; //导入依赖的package包/类
public static void main(String args[]) throws Exception {
String inputFileName = null;
String outputFileName = null;
boolean removePackFile = false;
boolean verbose = false;
boolean quiet = false;
boolean overrideDeflateHint = false;
boolean deflateHint = false;
String logFileName = null;
for (int i = 0; i < args.length; i++) {
if (args[i].equals("--help") || args[i].equals("-help")
|| args[i].equals("-h") || args[i].equals("-?")) {
printHelp();
return;
} else if(args[i].equals("-Htrue") || args[i].equals("--deflate-hint=true")) {
overrideDeflateHint = true;
deflateHint = true;
} else if(args[i].equals("-Hfalse") || args[i].equals("--deflate-hint=false")) {
overrideDeflateHint = true;
deflateHint = false;
} else if(args[i].equals("-Hkeep") || args[i].equals("--deflate-hint=keep")) {
overrideDeflateHint = false;
} else if(args[i].equals("-r") || args[i].equals("--remove-pack-file")) {
removePackFile = true;
} else if(args[i].equals("-v") || args[i].equals("--verbose")) {
verbose = true;
quiet = false;
} else if(args[i].equals("-q") || args[i].equals("--quiet")) {
quiet = true;
verbose = false;
} else if(args[i].startsWith("-l")) {
logFileName = args[i].substring(2);
} else if(args[i].equals("-V") || args[i].equals("--version")) {
printVersion();
return;
} else {
inputFileName = args[i];
if(args.length > i + 1) {
outputFileName = args[i+1];
}
break;
}
}
if(inputFileName == null || outputFileName == null) {
printUsage();
return;
}
Archive archive = new Archive(inputFileName, outputFileName);
archive.setRemovePackFile(removePackFile);
archive.setVerbose(verbose);
archive.setQuiet(quiet);
if(overrideDeflateHint) {
archive.setDeflateHint(deflateHint);
}
if(logFileName != null) {
archive.setLogFile(logFileName);
}
archive.unpack();
}
示例13: testWithSql
import org.apache.harmony.unpack200.Archive; //导入依赖的package包/类
public void testWithSql() throws Exception {
in = Archive.class
.getResourceAsStream("/org/apache/harmony/pack200/tests/sql.pack.gz");
file = File.createTempFile("sql", ".jar");
out = new JarOutputStream(new FileOutputStream(file));
Archive archive = new Archive(in, out);
archive.unpack();
JarFile jarFile = new JarFile(file);
file.deleteOnExit();
File compareFile = new File(Archive.class.getResource(
"/org/apache/harmony/pack200/tests/sqlUnpacked.jar").toURI());
JarFile jarFile2 = new JarFile(compareFile);
long differenceInJarSizes = Math.abs(compareFile.length()
- file.length());
assertTrue("Expected jar files to be a similar size, difference was "
+ differenceInJarSizes + " bytes", differenceInJarSizes < 100);
Enumeration entries = jarFile.entries();
Enumeration entries2 = jarFile2.entries();
while(entries.hasMoreElements() && entries2.hasMoreElements()) {
JarEntry entry = (JarEntry) entries.nextElement();
assertNotNull(entry);
String name = entry.getName();
JarEntry entry2 = (JarEntry) entries2.nextElement();
assertNotNull(entry2);
String name2 = entry2.getName();
assertEquals(name, name2);
InputStream ours = jarFile.getInputStream(entry);
InputStream expected = jarFile2.getInputStream(entry2);
BufferedReader reader1 = new BufferedReader(new InputStreamReader(ours));
BufferedReader reader2 = new BufferedReader(new InputStreamReader(
expected));
String line1 = reader1.readLine();
String line2 = reader2.readLine();
int i = 1;
while (line1 != null || line2 != null) {
assertEquals("Unpacked class files differ for " + name, line2, line1);
line1 = reader1.readLine();
line2 = reader2.readLine();
i++;
}
reader1.close();
reader2.close();
}
}
示例14: testWithSql
import org.apache.harmony.unpack200.Archive; //导入依赖的package包/类
public void testWithSql() throws Exception {
in = Archive.class
.getResourceAsStream("/org/apache/harmony/pack200/tests/sql.pack.gz");
file = File.createTempFile("sql", ".jar");
file.deleteOnExit();
out = new JarOutputStream(new FileOutputStream(file));
Archive archive = new Archive(in, out);
archive.unpack();
JarFile jarFile = new JarFile(file);
File compareFile = new File(Archive.class.getResource(
"/org/apache/harmony/pack200/tests/sqlUnpacked.jar").toURI());
JarFile jarFile2 = new JarFile(compareFile);
long differenceInJarSizes = Math.abs(compareFile.length()
- file.length());
assertTrue("Expected jar files to be a similar size, difference was "
+ differenceInJarSizes + " bytes", differenceInJarSizes < 100);
Enumeration entries = jarFile.entries();
Enumeration entries2 = jarFile2.entries();
while(entries.hasMoreElements() && entries2.hasMoreElements()) {
JarEntry entry = (JarEntry) entries.nextElement();
assertNotNull(entry);
String name = entry.getName();
JarEntry entry2 = (JarEntry) entries2.nextElement();
assertNotNull(entry2);
String name2 = entry2.getName();
assertEquals(name, name2);
InputStream ours = jarFile.getInputStream(entry);
InputStream expected = jarFile2.getInputStream(entry2);
BufferedReader reader1 = new BufferedReader(new InputStreamReader(ours));
BufferedReader reader2 = new BufferedReader(new InputStreamReader(
expected));
String line1 = reader1.readLine();
String line2 = reader2.readLine();
int i = 1;
while (line1 != null || line2 != null) {
assertEquals("Unpacked class files differ for " + name, line2, line1);
line1 = reader1.readLine();
line2 = reader2.readLine();
i++;
}
reader1.close();
reader2.close();
}
}