HashMap 简单取值

String wpu_no= "1";
 		String wpu_url= "2";
 		String wpu_pr_url="3";
 		String wpu_page_name="4";
 		String wpu_page_type="5";

         HashMap map=new HashMap();
         map.put("wpu_no",wpu_no);
         map.put("wpu_url",wpu_url);
         map.put("wpu_pr_url",wpu_pr_url);
         map.put("wpu_page_name",wpu_page_name);
         map.put("wpu_page_type",wpu_page_type);
         map.put("action","create");
        

        
         Iterator ite = map.keySet().iterator();
        
          while(ite.hasNext()){ 
        	 
        	  String   key   =   (String)ite.next();   //   key 
        	 System.out.println("-->"+key+"==>"+map.get(key));
           
          }

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
java编写智能合约_简单的⽤java代码实现智能合约 简单的⽤java代码实现智能合约 简单理解智能合约: 所谓智能合约,从另⼀个⾓度望过去,就是写⼊了不可篡改的电⼦账簿中的,可执⾏但不可篡改的程序代码⽽已。 ⼀、 编写⽣成jar包 ⼆、 通过⽂件流的⽅式读取jar,获取到每个class对象对应的字节数组 1.⾸先获取到jar对应的字节输⼊流 String jarPath = "/nghb/jar/MyFirstDemo.jar"; File file = new File(jarPath); System.out.println("⽂件的长度:"+file.length()); byte [] buffer = new byte[Integer.parseInt(String.valueOf(file.length()))]; FileInputStream fis = new FileInputStream(file); int size = Integer.parseInt(String.valueOf(file.length())); int offset; int read =0; //int result = fis.read(buffer,0,Integer.parseInt(String.valueOf(file.length()))); // 虽然知道了file⽂件的长度,但是还是要⽤for循环把流读到数组中,因为可能存在fis不⼀定会⼀次read完所有数据到字节数组中 for(offset = 0;(read = fis.read(buffer,offset,size-offset)) != -1 && offset < size; offset += read){ ; } 2.根据获取到的字节流输⼊数组,拆分字节流,拆分为jar包中每个类class对象对应的字节流 // JarInputStream专门⽤来处理jar包流的 JarInputStream jis = new JarInputStream(new ByteArrayInputStream(buffer)); Map byteMap = new HashMap(); JarEntry nextEntry = null; while((nextEntry=jis.getNextJarEntry()) != null){ if(!nextEntry.isDirectory() && nextEntry.getName().endsWith(".class")){ // 层层获取到jar包的jarEntry,替换为class对象中的className形式 String name = nextEntry.getName().replaceAll("/",".").replaceAll(".class",""); byte [] classByte = generateByteOfClass(jis); byteMap.put(name,classByte); } } /* * @Author ZDLS * @Description 根据流的⽅式,读⼊jar中的class对象对应的字节流 * @Date 下午 16:44 2021/1/26 0026 * @Param * @return */ private byte [] generateByteOfClass(JarInputStream jarInputStream) throws Exception{ List bufs = null; byte [] result = null; int total = 0; // 整数的最⼤取值 int remaining = 2147483647; int n=0; do{ byte [] buf = new byte[Math.min(remaining,8192)]; int nread = 0; // 跳出for循环的情况有:buf不够⽤,这个时间n为0;流读取完了n的返回值为-1 for(nread=0; (n = jarInputStream.read(buf,nread,Math.min(buf.length - nread,remaining)))>0;remaining -= n){ nread += n; } if(nread > 0){ if(2147483639 - total < nread){ System.out.println("抛出异常"); } total += nread; if(result == null){ result = buf; }else { if(bufs == null){ bufs = new Ar

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值