package com.test;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
public class ReadData {
public static void main(String args[])throws Exception{
File f = new File("/home/upload/TwitterBig.zip");
InputStream in = new FileInputStream(f);
byte bytes[]=new byte[(int)f.length()]; //创建合适文件大小的数组
in.read(bytes); //读取文件中的内容到b[]数组
in.close();
ByteArrayInputStream fis = new ByteArrayInputStream(bytes);
ZipInputStream zis = new ZipInputStream(fis);
ZipEntry ze = null;
while((ze = zis.getNextEntry()) != null){
String name = ze.getName();
System.out.println("File name****"+ze.getName());
long size = ze.getSize();
byte[] binary = readZipEntry(zis,size);
writeFile(binary,"/home/upload/parese/"+ze.getName());
}
}
private static byte[] readZipEntry(ZipInputStream zipIn, long size)
throws Exception {
ByteArrayOutputStream output = new ByteArrayOutputStream();
int oneByte = -1;
long offset = 0L;
try {
while ((oneByte = zipIn.read()) > -1) {
output.write((byte) oneByte);
offset++;
if (offset == size) {
break;
}
}
} finally {
output.close();
}
return output.toByteArray();
}
private static void writeFile(byte[] content, String filename) throws IOException {
File file = new File(filename);
if (!file.exists()) {
file.createNewFile();
}
FileOutputStream fop = new FileOutputStream(file);
BufferedOutputStream buff = new BufferedOutputStream(fop);
buff.write(content);
buff.flush();
buff.close();
}
}
分享到:
相关推荐
[√] 完善安装,创建临时数据文件 [√] Pfa内置采集类和Snoopy类 [√] 完善后台首页显示 [√] 完善安装程序界面美化/英文语言文件 [√] 安装设置增强(1数据库连接类型设置,2数据库端口, 3管理员邮箱) [√] ...
18:单线程下载时不能创建临时文件. 19:下载流文件(rm,Media Player). Notepad++ V5.6.8 源码! 如题。 OA精灵代码 c++版 一套oa系统。 ocxdlgtest dll的一个实例。 OD反汇编引擎(带VC修改版和原版) 如题。主要...
支持下载 m3u8 链接或文件为 mp4 或 ts 格式,并提供丰富的命令行选项。m3u8 downloader 开源的命令行 m3u8/HLS/dash 下载器,支持普通 AES-128-CBC 解密,多线程,自定义请求头等。支持简体中文,繁体中文和英文,...
它们只包含临时文件。 - 在/deploy 或/webapps 文件夹中复制war 文件。 - 启动你的 tomcat。 - 将浏览器指向: - 在 html 表单中输入测试参数并按下提交按钮 - 生成的类似 adf 的 xml post 请求将被转发到 Web 服务...
当生成的压缩文件是自解压的并且压缩文件大小超过 4 GB,WinRAR 显示一个警告。 Windows 不能运行应用程序。 of such size. <br> 5. 修正 ISO 处理的代码。 <br> 版本 3.70 beta 2 <br> 1. 压缩...
实现了 清楚internet临时文件、Cookie的清除、游览器地址栏历史地址的清除、清楚表单自动完成历史记录、清楚自动密码历史记录、清除收藏夹中的内容、清除RAS自动拨号历史记录、清除系统临时文件夹、清空回收站、清除...
实现了 清楚internet临时文件、Cookie的清除、游览器地址栏历史地址的清除、清楚表单自动完成历史记录、清楚自动密码历史记录、清除收藏夹中的内容、清除RAS自动拨号历史记录、清除系统临时文件夹、清空回收站、清除...
实现了 清楚internet临时文件、Cookie的清除、游览器地址栏历史地址的清除、清楚表单自动完成历史记录、清楚自动密码历史记录、清除收藏夹中的内容、清除RAS自动拨号历史记录、清除系统临时文件夹、清空回收站、清除...
实现了 清楚internet临时文件、Cookie的清除、游览器地址栏历史地址的清除、清楚表单自动完成历史记录、清楚自动密码历史记录、清除收藏夹中的内容、清除RAS自动拨号历史记录、清除系统临时文件夹、清空回收站、清除...
实现了 清楚internet临时文件、Cookie的清除、游览器地址栏历史地址的清除、清楚表单自动完成历史记录、清楚自动密码历史记录、清除收藏夹中的内容、清除RAS自动拨号历史记录、清除系统临时文件夹、清空回收站、清除...
参数值:超链接上传前限制的文件扩展名列表,默认为:zip,rar,txt,建议与服务端扩展名检查列表一致 upImgUrl:图片文件上传接收URL 参数值:接收用户上传的服务器端程序URL,默认留空为禁用上传功能,具体使用方法...