pack and unpack

package test;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;

public class ZipFloder {

 private static int i;

 public static void main(String args[]) throws IOException {
  unpack();

 }

 private static void unpack() throws IOException {
  // TODO Auto-generated method stub
  String compress = "nutch-0.9.tar.gz";// zip压缩文件

  String decompression = "/f1";// 解压路径

  java.io.File dir = new java.io.File(decompression);

  java.util.zip.ZipFile zf = new java.util.zip.ZipFile(compress);

  java.util.Enumeration enumer = zf.entries();

  while (enumer.hasMoreElements()) {

   java.util.zip.ZipEntry ze = (java.util.zip.ZipEntry) enumer
     .nextElement();

   String zename = ze.getName();

   zename = new String(zename);// 文件名,不支持中文.

   System.out.println(zename);

   if (ze.isDirectory()) {
    java.io.File file = new java.io.File(dir.getAbsolutePath()
      + "/" + zename);

    file.mkdirs();
   } else {
    java.io.File file = new java.io.File(dir.getAbsolutePath()
      + "/" + zename).getParentFile();

    if (!file.exists()) {
     file.mkdirs();
    }
    byte zeby[] = new byte[(int) ze.getSize()];

    java.io.InputStream is = zf.getInputStream(ze);

    is.read(zeby);

    is.close();

    java.io.FileOutputStream fos = new java.io.FileOutputStream(dir
      .getAbsolutePath()
      + "/" + zename);

    fos.write(zeby);

    fos.close();
   }
  }
  zf.close();

 }

 private static void pack() throws IOException {
  // TODO Auto-generated method stub

  String compress = "/f2";// 要压缩的目录

  String decompression = "test.rar";// 压缩路径

  java.util.zip.ZipOutputStream zos = new java.util.zip.ZipOutputStream(
    new java.io.FileOutputStream(new java.io.File(decompression)));

  compress(zos, new File(compress));

  zos.close();
  System.out.println("the files count: " + i);
 }

 public static void compress(java.util.zip.ZipOutputStream zos,
   java.io.File file) throws java.io.IOException {
  if (file.isFile()) {
   byte by[] = new byte[(int) file.length()];

   java.io.FileInputStream is = new java.io.FileInputStream(file);

   is.read(by);

   is.close();

   java.util.zip.ZipEntry ze = new java.util.zip.ZipEntry(file
     .getPath());

   zos.putNextEntry(ze);

   zos.write(by);

   zos.closeEntry();
   System.out.println(file.getName());
  } else if (file.isDirectory()) {
   java.io.File files[] = file.listFiles();

   if (files != null)
    for (File f : files) {
     compress(zos, f);
     i++;
    }
  }

 }
}

内容概要:本文全面介绍了数据流图(DFD)的概念、构成元素及其重要性。数据流图是从数据传递和加工的角度,以图形方式表达系统逻辑功能、数据流向和变换过程的工具。文章详细解释了数据流图的四个基本元素:数据流、加工、数据存储和外部实体,并通过实例说明了这些元素在实际场景中的应用。文中强调了数据流图在软件开发需求分析和业务流程优化中的关键作用,通过绘制顶层、中层和底层数据流图,逐步细化系统功能,确保数据流向和处理逻辑的清晰性。此外,文章还指出了常见绘制误区及解决方法,并以在线购物系统为例进行了实战分析,展示了从需求分析到数据流图绘制的全过程。 适合人群:软件工程师、业务分析师、系统设计师以及对系统分析与设计感兴趣的初学者。 使用场景及目标:①帮助开发团队在需求分析阶段清晰展示数据流动和处理过程,避免理解偏差;②辅助企业梳理和优化业务流程,识别效率低下的环节,提升运营效率;③为系统设计和开发提供详细的逻辑框架,确保各模块的功能明确,减少开发错误。 阅读建议:本文内容详实,涵盖了从理论到实践的各个方面。建议读者在学习过程中结合实际项目背景,逐步掌握数据流图的绘制技巧,并通过反复练习和优化,加深对系统分析与设计的理解。
资源下载链接为: https://pan.quark.cn/s/5c50e6120579 《CoffeeTime_0.99.rar:主板BIOS修改工具详述》 在计算机硬件领域,BIOS(基本输入输出系统)是计算机启动时最先加载的软件,它负责初始化硬件设备,并为操作系统提供基本的交互功能。不过,随着处理器技术的持续进步,部分主板可能无法原生支持更新的CPU型号。为解决这一问题,一些技术爱好者和专业人士会通过修改主板BIOS,也就是俗称的“魔改”,来提升其兼容性。本文将深入剖析名为“CoffeeTime_0.99.rar”的工具,它是一款专门用于主板BIOS修改,以实现对第6、7、8、9代英特尔CPU支持的工具。 我们先来看“CoffeeTime.exe”,这是该工具的主程序文件。通常情况下,它会配备一套直观易用的用户界面,方便用户对BIOS进行修改操作。不过,在使用该工具之前,用户必须具备一定的电脑硬件知识,因为一旦操作失误,就可能导致系统运行不稳定,甚至无法启动。对于初学者而言,谨慎操作至关重要,否则可能会造成不可挽回的损失。 “readme.txt”是软件包中常见的文档,一般会包含使用指南、注意事项以及开发者提供的其他重要信息。在使用CoffeeTime之前,用户务必要仔细阅读该文件,因为里面可能包含了如何正确运行程序、避免错误操作以及解压后具体步骤等关键内容。 “bin”和“data”是两个文件夹,它们可能包含了用于BIOS修改的各种二进制文件和数据。“bin”文件夹通常会包含特定版本的BIOS固件或用于修改的工具,而“data”文件夹则可能包含更新CPU微码、识别信息等必要的数据文件。在进行BIOS修改的过程中,这些文件会被程序调用,从而实现对原有BIOS的扩展或修正。 BIOS的修改过程一般包含以下步骤:首先,备份原始BIOS,这是在进行任何修改前的必要步骤,以便
### UVM Unpack Usage and Examples in SystemVerilog In the Universal Verification Methodology (UVM), `unpack` operations typically occur within transaction objects where data is transferred between testbench components or when converting packed structures into classes with unpacked members. The operation facilitates easier manipulation of data by allowing fields to be accessed individually rather than as part of a single large bit vector. For instance, consider a scenario involving packet transactions which contain various headers such as Ethernet, IP, TCP/UDP etc., each header having multiple fields like source address, destination address, port numbers among others. Instead of handling all these bits together, one can define class properties corresponding to individual field values and implement methods for packing/unpacking them from/to byte arrays during transmission across interfaces[^1]. Below demonstrates how this might look in practice: ```systemverilog class my_transaction extends uvm_sequence_item; rand bit [7:0] src_mac_addr[]; rand bit [7:0] dst_mac_addr[]; // ... other declarations ... function new(string name="my_transaction"); super.new(name); src_mac_addr = new[6]; dst_mac_addr = new[6]; endfunction : new virtual function void do_unpack(); int unsigned idx=0; foreach(src_mac_addr[i]) begin $readmemh($sformatf("src_%0d", i), src_mac_addr[i]); idx++; end foreach(dst_mac_addr[j]) begin $readmemh($sformatf("dst_%0d", j), dst_mac_addr[j]); idx++; end // Continue reading remaining items... endfunction : do_unpack endclass : my_transaction ``` This example shows only MAC addresses being read back via `$readmemh`, but similar logic applies to any set of bytes representing different parts of network packets. Note also that actual implementations may vary depending on specific requirements; here just illustrates basic principles behind implementing custom pack/unpack routines inside UVM-based verification environments. --related questions-- 1. How does the implementation differ when dealing with variable-length fields? 2. What considerations should be taken into account while designing user-defined types supporting both pack and unpack functionalities? 3. Can you provide more complex examples including checksum calculation during pack/unpack processes? 4. Is there support for automatic generation tools assisting developers in creating pack/unpack functions?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值