//1.byte[]转file
File jpg = new File("D:\\aaa.jpg");
FileOutputStream fileout = new FileOutputStream(jpg);
fileout.write(fileByte);
fileout.close();
//2.file转byte[]
File zipFile = new File("D:\\aaa.jpg
");
FileInputStream fin = new FileInputStream(zipFile);
ByteArrayOutputStream bos = new ByteArrayOutputStream(1024);
byte[] b = new byte[1024];
int n;
while ((n = fin.read(b)) != -1) {
}
bos.toByteArray()
//3.生成压缩包
private ZipOutputStream jos;
ZipEntry sourEntry = null;
File zipFile = new File("D:\\aaa.zip
");
jos = new ZipOutputStream(new FileOutputStream(zipFile));
sourEntry = new ZipEntry(String.valueOf(new Date().getTime()) + ".jpg");
jos.putNextEntry(sourEntry);
//在此处,如果多个文件打包则new多个
ZipEntry
jos.write(fileByte); //此处我写入的是一个byte[] 如果文件为file则需要自行转换成byte[] 如例2
jos.closeEntry();
jos.close();
//4.写入excel
WritableWorkbook wwb = null;
//5.读取excel
InputStream instream = new FileInputStream("D:\\work_self\\文档\\rjs_jz.xls");
jxl.Workbook wbk = Workbook.getWorkbook(instream);
Sheet sheet = wbk.getSheet(0);
for (int i = 0; i < sheet.getRows(); i++) {
}