gpt4 book ai didi

net.sz.framework.utils.ZipUtil类的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 09:59:15 26 4
gpt4 key购买 nike

本文整理了Java中net.sz.framework.utils.ZipUtil类的一些代码示例,展示了ZipUtil类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipUtil类的具体详情如下:
包路径:net.sz.framework.utils.ZipUtil
类名称:ZipUtil

ZipUtil介绍

[英]author 失足程序员
blog http://www.cnblogs.com/shizuchengxuyuan/
mail 492794628@qq.com
phone 13882122019
[中]著者失足程序员
博客http://www.cnblogs.com/shizuchengxuyuan/
邮政492794628@qq.com
电话13882122019

代码示例

代码示例来源:origin: shizuchengxuyuan/net.sz.java

/**
 * 默认 字符集 utf-8 读取内容
 *
 * @param zipPath zip文件路径和名字
 * @param filename zip文件中的文件名字
 * @return
 */
public static String loadStringZipFile(String zipPath, String filename) {
  return loadStringZipFile(zipPath, filename, "utf-8");
}

代码示例来源:origin: shizuchengxuyuan/net.sz.java

/**
 *
 * @param zipPath zip文件路径和名字
 * @param filename zip文件中的文件名字
 * @param charsetName 字符集 utf-8
 * @return
 */
public static String loadStringZipFile(String zipPath, String filename, String charsetName) {
  try {
    byte[] loadZipFile = loadZipFile(zipPath, filename);
    if (loadZipFile == null) {
      return null;
    }
    return new String(loadZipFile, charsetName);
  } catch (Throwable ex) {
    throw new UnsupportedOperationException(ex);
  }
}

代码示例来源:origin: shizuchengxuyuan/net.sz.java

public static void main(String[] args) {
  String zipString = zipString("sdfagasgasf阿萨德刚发生的嘎嘎额外嘎斯vfasfsgag");
  System.out.println(zipString);
  System.out.println(unZipString(zipString));
  System.exit(0);
}

代码示例来源:origin: shizuchengxuyuan/net.sz.java

/**
   * 书写对象字节流,并且压缩
   *
   * @param obj
   * @param filePath
   */
  public static void writerZipObjectFile(Object obj, String filePath) {
    byte[] zipObject = ZipUtil.zipObject(obj);
    writerFile(zipObject, filePath);
  }
}

代码示例来源:origin: shizuchengxuyuan/net.sz.java

/**
 * 读取文件内容,解压缩,返回对象
 *
 * @param filePath
 * @return
 */
public static Object readFileToZipObject(String filePath) {
  byte[] readFileToBytes = readFileToZipBytes(filePath);
  return ZipUtil.unZipObject(readFileToBytes);
}

代码示例来源:origin: shizuchengxuyuan/net.sz.java

/**
 *
 * @param zipPath zip文件名和路径,
 * @param fileName 存入zip文件的文件名
 * @param source 默认会是utf-8编码
 */
public static void writeStringZip(String zipPath, String fileName, String source) {
  writeStringZip(zipPath, fileName, source, "utf-8");
}

代码示例来源:origin: shizuchengxuyuan/net.sz.java

/**
 * 使用zip进行压缩
 *
 * @param object 压缩前
 * @return 返回压缩后
 */
public static final byte[] zipObject(Object object) {
  if (object == null) {
    return null;
  }
  return zip(ObjectStreamUtil.toBytes(object));
}

代码示例来源:origin: shizuchengxuyuan/net.sz.java

/**
 *
 * @param zipPath zip文件名和路径,
 * @param fileName 存入zip文件的文件名
 * @param source
 * @param charsetName 编码字符集
 */
public static void writeStringZip(String zipPath, String fileName, String source, String charsetName) {
  try {
    byte[] bytes = source.getBytes(charsetName);
    writeZip(zipPath, fileName, bytes);
  } catch (Throwable ex) {
    throw new UnsupportedOperationException(ex);
  }
}

代码示例来源:origin: shizuchengxuyuan/net.sz.java

/**
 * 使用zip进行解压缩
 *
 * @param bytes 压缩后
 * @return
 */
public static final Object unZipObject(byte[] bytes) {
  byte[] unZip = unZip(bytes);
  return ObjectStreamUtil.toObject(unZip);
}

代码示例来源:origin: shizuchengxuyuan/net.sz.java

break;
default: {
  stmt.setBytes(nums, ZipUtil.zipObject(value));

代码示例来源:origin: shizuchengxuyuan/net.sz.java

if (ConvertTypeUtil.TypeCode.Default.equals(typeCode)) {
  byte[] bytes = (byte[]) obj;
  obj = ZipUtil.unZipObject(bytes);
} else {
  obj = ConvertTypeUtil.changeType(obj, columnType);

代码示例来源:origin: shizuchengxuyuan/net.sz.java

/**
 * 把xml数据写到zip文件中
 *
 * @param zipPath
 * @param fileName
 * @param object
 */
public static void writerXmlZip(String zipPath, String fileName, Object object) {
  String toXMLString = writerXml(object);
  ZipUtil.writeStringZip(zipPath, fileName, toXMLString, "utf-8");
}

代码示例来源:origin: shizuchengxuyuan/net.sz.java

/**
 * 读取文件并且解压缩字节
 *
 * @param filePath
 * @return
 */
public static byte[] readFileToZipBytes(String filePath) {
  File file = new File(filePath);
  try (FileInputStream in = new FileInputStream(file)) {
    Long filelength = file.length();     //获取文件长度
    byte[] filecontent = new byte[filelength.intValue()];
    in.read(filecontent);
    return ZipUtil.zip(filecontent);//返回文件内容,默认编码
  } catch (Throwable ex) {
    throw new UnsupportedOperationException("读取文件内容", ex);
  }
}

代码示例来源:origin: shizuchengxuyuan/net.sz.java

/**
 *
 * @param zipPath zip文件名和路径,
 * @param fileName 存入zip文件的文件名 建议文件名是 .db 或者 .tmp
 * @param source 默认会是utf-8编码
 */
public static void writeObjectZip(String zipPath, String fileName, Object source) {
  try {
    byte[] bytes = ObjectStreamUtil.toBytes(source);
    writeZip(zipPath, fileName, bytes);
  } catch (Throwable ex) {
    throw new UnsupportedOperationException(ex);
  }
}

代码示例来源:origin: shizuchengxuyuan/net.sz.java

stmt.setObject(nums, null);
} else {
  stmt.setBytes(nums, ZipUtil.zipObject(value));

代码示例来源:origin: shizuchengxuyuan/net.sz.java

/**
 * 把xml数据写到zip文件中
 *
 * @param object
 * @param fileName
 * @param zipPath
 */
public static void writerSimpleXmlZip(Object object, String fileName, String zipPath) {
  //使用GZIPOutputStream包装OutputStream流,使其具体压缩特性,最后会生成test.txt.gz压缩包
  //并且里面有一个名为test.txt的文件
  String toXMLString = witerSimpleXml(object);
  ZipUtil.writeStringZip(zipPath, fileName, toXMLString);
}

代码示例来源:origin: shizuchengxuyuan/net.sz.java

/**
 * 使用zip进行压缩
 *
 * @param str 压缩前的文本
 * @return 返回压缩后的文本
 */
public static final String zipString(String str) {
  if (str == null) {
    return null;
  }
  try {
    byte[] zip = zip(str.getBytes("utf-8"));
    return StringUtil.convertToBase64String(zip);
  } catch (Throwable ex) {
    throw new UnsupportedOperationException(ex);
  }
}

代码示例来源:origin: shizuchengxuyuan/net.sz.java

/**
 *
 * @param zipPath zip文件路径和名字
 * @param filename zip文件中的文件名字
 * @return
 */
public static Object loadObjectZipFile(String zipPath, String filename) {
  byte[] loadZipFile = loadZipFile(zipPath, filename);
  if (loadZipFile == null) {
    return null;
  }
  return ObjectStreamUtil.toObject(loadZipFile);
}

代码示例来源:origin: shizuchengxuyuan/net.sz.java

/**
 *
 * @param <T>
 * @param zipPath zip文件路径和名字
 * @param filename zip文件中的文件名字
 * @param clazz
 * @return
 */
public static <T> T loadObjectZipFile(String zipPath, String filename, Class<T> clazz) {
  byte[] loadZipFile = loadZipFile(zipPath, filename);
  if (loadZipFile == null) {
    return null;
  }
  return (T) ObjectStreamUtil.toObject(loadZipFile);
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com