本文整理了Java中com.wizzardo.tools.io.ZipTools
类的一些代码示例,展示了ZipTools
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipTools
类的具体详情如下:
包路径:com.wizzardo.tools.io.ZipTools
类名称:ZipTools
暂无
代码示例来源:origin: wizzardo/tools
public static List<File> unzip(File zipFile, File outDir) {
return unzip(zipFile, outDir, null);
}
代码示例来源:origin: wizzardo/tools
public static File zip(String file) {
return zip(new File(file));
}
代码示例来源:origin: wizzardo/tools
public static boolean isZip(File f) {
FileInputStream in = null;
try {
in = new FileInputStream(f);
} catch (FileNotFoundException e) {
throw Unchecked.rethrow(e);
}
byte[] b = new byte[2];
try {
in.read(b);
} catch (IOException ex) {
throw Unchecked.rethrow(ex);
} finally {
IOTools.close(in);
}
return isZip(b);
}
代码示例来源:origin: wizzardo/tools
public static void zip(ZipOutputStream out, File toZip) {
File startDir = toZip.getParentFile();
zipping(out, FileTools.listRecursive(toZip), startDir);
}
代码示例来源:origin: wizzardo/http
@Override
public List<Class> getClasses() {
List<Class> l = new ArrayList<Class>();
File dir;
if (Holders.getEnvironment() != Environment.TEST)
System.out.println("classpath: " + classpath);
for (String path : classpath) {
dir = new File(path);
if (!filterClasspath(dir))
continue;
if (Holders.getEnvironment() != Environment.TEST)
System.out.println("searching for classes in " + dir.getAbsolutePath());
if (!dir.exists())
continue;
if (dir.isDirectory())
getClasses(dir, dir, l);
else if (ZipTools.isZip(dir)) {
getClasses(dir, l);
}
}
return l;
}
代码示例来源:origin: wizzardo/tools
public static void unzip(File zipFile, ZipEntryConsumer consumer) {
unzip(zipFile, consumer, null);
}
代码示例来源:origin: wizzardo/tools
public static File zip(File toZip) {
ZipOutputStream zipout = null;
File zip = new File(toZip.getAbsolutePath() + ".zip");
try {
zipout = new ZipOutputStream(new FileOutputStream(zip));
zip(zipout, toZip);
} catch (IOException ex) {
throw Unchecked.rethrow(ex);
} finally {
IOTools.close(zipout);
}
return zip;
}
代码示例来源:origin: wizzardo/tools
public static List<File> unzip(File zipFile, final File outDir, ZipEntryFilter filter) {
final List<File> l = new ArrayList<File>();
unzip(zipFile, new ZipEntryConsumer() {
byte[] b = new byte[1024 * 50];
@Override
public void consume(String name, InputStream in) {
File outFile = new File(outDir, name);
outFile.getParentFile().mkdirs();
FileOutputStream out = null;
try {
out = new FileOutputStream(outFile);
IOTools.copy(in, out, b);
l.add(outFile);
} catch (IOException ex) {
outFile.delete();
throw Unchecked.rethrow(ex);
} finally {
IOTools.close(out);
}
}
}, filter);
return l;
}
代码示例来源:origin: wizzardo/tools
@Override
public void write(ZipOutputStream out) throws IOException {
if (file.isFile()) {
FileInputStream in = null;
try {
in = new FileInputStream(file);
ZipEntry entry = new ZipEntry(file.getName());
entry.setMethod(ZipEntry.DEFLATED);
out.putNextEntry(entry);
IOTools.copy(in, out);
} finally {
IOTools.close(in);
}
} else {
zip(out, file);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!