本文整理汇总了Java中org.lemurproject.galago.utility.ZipUtil.listZipFile方法的典型用法代码示例。如果您正苦于以下问题:Java ZipUtil.listZipFile方法的具体用法?Java ZipUtil.listZipFile怎么用?Java ZipUtil.listZipFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.lemurproject.galago.utility.ZipUtil
的用法示例。
在下文中一共展示了ZipUtil.listZipFile方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testZipFile
import org.lemurproject.galago.utility.ZipUtil; //导入方法依赖的package包/类
@Test
public void testZipFile() throws IOException {
File tmp = null;
try {
tmp = File.createTempFile("zipUtilTest", ".zip");
String fooContents = "foo is the best";
String fooPath = "data/foo.txt";
String barContents = "bar is the best";
String barPath = "data/subdir/ignore/bar.txt";
// write zip file:
ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(tmp.getAbsolutePath()));
ZipUtil.write(zos, fooPath, ByteUtil.fromString(fooContents));
ZipUtil.write(zos, barPath, ByteUtil.fromString(barContents));
zos.close();
ZipFile zipFile = ZipUtil.open(tmp);
// read zip file:
List<String> entries = ZipUtil.listZipFile(zipFile);
assertEquals(2, entries.size());
assertEquals(fooPath, entries.get(0));
assertEquals(barPath, entries.get(1));
assertEquals(fooContents, StreamUtil.copyStreamToString(ZipUtil.streamZipEntry(zipFile, fooPath)));
assertEquals(barContents, StreamUtil.copyStreamToString(ZipUtil.streamZipEntry(zipFile, barPath)));
assertTrue(ZipUtil.hasZipExtension(tmp.getAbsolutePath()));
} finally {
if (tmp != null) {
tmp.delete();
}
}
}
示例2: testZipFile
import org.lemurproject.galago.utility.ZipUtil; //导入方法依赖的package包/类
@Test
public void testZipFile() throws IOException {
File tmp = null;
try {
tmp = File.createTempFile("streamParserZipTest", ".zip");
String fooContents = "foo is the best";
String fooPath = "data/foo.txt";
String barContents = "bar is the best";
String barPath = "data/subdir/ignore/bar.txt";
String trecWebContents = "<DOC>\n"
+ "<DOCNO>CACM-0001</DOCNO>\n"
+ "<DOCHDR>\n"
+ "http://www.yahoo.com:80 some extra text here\n"
+ "even more text in this part\n"
+ "</DOCHDR>\n"
+ "This is some text in a document.\n"
+ "</DOC>\n";
String trecWebPath = "data/blah/easy.trecweb";
String guessTrecWebPath = "data/blah/guess_trecweb";
// write zip file:
ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(tmp.getAbsolutePath()));
ZipUtil.write(zos, fooPath, ByteUtil.fromString(fooContents));
ZipUtil.write(zos, barPath, ByteUtil.fromString(barContents));
ZipUtil.write(zos, trecWebPath, ByteUtil.fromString(trecWebContents));
ZipUtil.write(zos, guessTrecWebPath, ByteUtil.fromString(trecWebContents));
zos.close();
ZipFile zipFile = ZipUtil.open(tmp);
// read zip file:
List<String> entries = ZipUtil.listZipFile(zipFile);
assertEquals(4, entries.size());
zipFile.close();
List<DocumentSplit> splits = DocumentSource.processZipFile(tmp, Parameters.create());
assertEquals(4, splits.size());
assertEquals("txt", splits.get(0).fileType);
assertEquals("txt", splits.get(1).fileType);
assertEquals("trecweb", splits.get(2).fileType);
assertEquals("trecweb", splits.get(3).fileType);
DocumentStreamParser parser = DocumentStreamParser.create(splits.get(2), Parameters.create());
Document d = parser.nextDocument();
assertNotNull(d);
assertNull(parser.nextDocument());
parser.close();
assertEquals("http://www.yahoo.com", d.metadata.get("url"));
assertEquals(tmp.getAbsolutePath() + "!" + fooPath, DocumentStreamParser.getFullPath(splits.get(0)));
} finally {
if (tmp != null) {
tmp.delete();
}
}
}
示例3: testForcedZipFile
import org.lemurproject.galago.utility.ZipUtil; //导入方法依赖的package包/类
@Test
public void testForcedZipFile() throws IOException {
File tmp = null;
try {
tmp = File.createTempFile("zipUtilTest", ".zip");
String fooContents = "foo is the best";
String fooPath = "data/foo.txt";
String trecWebContents = "<DOC>\n"
+ "<DOCNO>CACM-0001</DOCNO>\n"
+ "<DOCHDR>\n"
+ "http://www.yahoo.com:80 some extra text here\n"
+ "even more text in this part\n"
+ "</DOCHDR>\n"
+ "This is some text in a document.\n"
+ "</DOC>\n";
String trecWebPath = "data/blah/easy.trecweb";
// write zip file:
ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(tmp.getAbsolutePath()));
ZipUtil.write(zos, fooPath, ByteUtil.fromString(fooContents));
ZipUtil.write(zos, trecWebPath, ByteUtil.fromString(trecWebContents));
zos.close();
ZipFile zipFile = ZipUtil.open(tmp);
// read zip file:
List<String> entries = ZipUtil.listZipFile(zipFile);
assertEquals(2, entries.size());
zipFile.close();
List<DocumentSplit> splits = DocumentSource.processZipFile(tmp, Parameters.parseArray("filetype", "foo"));
assertEquals(2, splits.size());
assertEquals("foo", splits.get(0).fileType);
assertEquals("foo", splits.get(1).fileType);
} finally {
if(tmp != null) assertTrue(tmp.delete());
}
}
示例4: testZipFile
import org.lemurproject.galago.utility.ZipUtil; //导入方法依赖的package包/类
@Test
public void testZipFile() throws IOException {
File tmp = null;
try {
tmp = File.createTempFile("zipUtilTest", ".zip");
String fooContents = "foo is the best";
String fooPath = "data/foo.txt";
String barContents = "bar is the best";
String barPath = "data/subdir/ignore/bar.txt";
String trecWebContents = "<DOC>\n"
+ "<DOCNO>CACM-0001</DOCNO>\n"
+ "<DOCHDR>\n"
+ "http://www.yahoo.com:80 some extra text here\n"
+ "even more text in this part\n"
+ "</DOCHDR>\n"
+ "This is some text in a document.\n"
+ "</DOC>\n";
String trecWebPath = "data/blah/easy.trecweb";
String guessTrecWebPath = "data/blah/guess_trecweb";
// write zip file:
ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(tmp.getAbsolutePath()));
ZipUtil.write(zos, fooPath, ByteUtil.fromString(fooContents));
ZipUtil.write(zos, barPath, ByteUtil.fromString(barContents));
ZipUtil.write(zos, trecWebPath, ByteUtil.fromString(trecWebContents));
ZipUtil.write(zos, guessTrecWebPath, ByteUtil.fromString(trecWebContents));
zos.close();
ZipFile zipFile = ZipUtil.open(tmp);
// read zip file:
List<String> entries = ZipUtil.listZipFile(zipFile);
assertEquals(4, entries.size());
zipFile.close();
List<DocumentSplit> splits = DocumentSource.processZipFile(tmp, Parameters.create());
assertEquals(4, splits.size());
assertEquals("txt", splits.get(0).fileType);
assertEquals("txt", splits.get(1).fileType);
assertEquals("trecweb", splits.get(2).fileType);
assertEquals("trecweb", splits.get(3).fileType);
} finally {
if(tmp != null) assertTrue(tmp.delete());
}
}