zoukankan      html  css  js  c++  java
  • Enumeration接口的用法

    Enumeration接口的用法

    标签: iteratorvector
     分类:

    Enumeration接口也在java.util包中 它的功能与Iterator差不多 都是用来遍历集合中的元素  但是枚举Enumeration只提供了遍历Vector和Hashtable类型集合元素的功能  这种类型的集合对象通过调用elements()方法获取一个Enumeration对象  然后Enumeratino对象再调用以下方法来对集合中的元素进行遍历

    hasMoreElements():判断Enumeration对象中是否还有数据

    nextElement():获取Enumeration对象中的下一个数据

    如:

    Enumeration names = request.getHeaderNames(); 

    while(names.hasMoreElements()){

    String name = (String)names.nextElement();

    out.println("<b>"+  name +":</b>"+ request.getHeader(name) +"<br />");  if(name.equals("user-agent")){

    out.println("<a href='#'>"+name+":"+request.getHeader(name)+"</a><br />");

    }

    表头输出结果:

    host:localhost:8080    //端口号

    connection:keep-alive  //

    user-agent:Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.142 Safari/535.19  //浏览器信息

    user-agent:Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.142 Safari/535.19

    accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8  //浏览器支持格式

    accept-encoding:gzip,deflate,sdch      //

    accept-language:zh-CN,zh;q=0.8

    accept-charset:GBK,utf-8;q=0.7,*;q=0.3

    Cookie:account=Helloween   //用户当前的状态

    Referer:http://www.baidu.com  //从哪个页面单击进入的

  • 相关阅读:
    AutoLISP批量移动图元到指定图层
    AutoLISP实现同时绘制多条直线
    再测试下连接微博
    一个博士的论文致谢词
    AutoLISP实现橡皮筋绘图预览
    AutoLISP根据所选图元冻结图层
    AutoCAD中绘制箭头
    你是谁的流川枫
    AutoLISP反应器vlrobjectreactor函数应用
    AutoLISP实时跟踪鼠标坐标
  • 原文地址:https://www.cnblogs.com/xiaona19841010/p/5153064.html
Copyright © 2011-2022 走看看