zoukankan      html  css  js  c++  java
  • 一个使用矢量的例子!

        public static void main(String[] arg) {
            //new CommonUtil().readFile("c:/content.txt");
            Connection conn = null;
            try {
                //System.out.println(URLEncoder.encode("E:\\fish\\P0001\\中文", "UTF-8"));
                //System.out.println(URLEncoder.encode("E:\\fish\\P0001\\test","GBK"));
                //System.out.println(URLDecoder.decode("E%3A%5Cfish%5CP0001_02_txl%5CCoding%5Cwebtxl%5Cmyfile%5C1147094473625%5C%C4%BF%C2%BC", "GBk"));
                //Vector v = FileInfo.getAllFiles("E:\\fish\\P0001_02_txl\\Coding\\webtxl\\myfile\\1147094473625");
                //for (int i=0;i<v.size();i++) {
                //System.out.println(v.get(i));
                //}
                //DataOutputStream os = null;
                //DataInputStream is = null;
                //ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(new File("c:/test.zip")));
                //zos.setComment("zip by test");
                //zos.setMethod(ZipOutputStream.DEFLATED);
                // for (int i=0;i<v.size();i++) {
                //String fileName = v.get(i).toString();
                //String fileName ="E:\\fish\\P0001_02_txl\\Coding\\webtxl\\myfile\\1147094473625";
                //zip(zos, fileName, "");
                // }
                //zos.close();
                //DecimalFormat df1 = new DecimalFormat("###0.00");
                //System.out.println(df1.format(1.333333));
                Class.forName("com.jnetdirect.jsql.JSQLDriver");
                conn = DriverManager.getConnection(
                    "jdbc:JSQLConnect://192.168.1.88:1433/canv", "sa", "canv");
                String sql = "select occupation,username from sync4j_user where occupation is not null and occupation <>'' order by occupation";
                DBUtil db = new DBUtil();
                ResultSet rs = (ResultSet) db.doSql(sql, db.QUERY_MODE, conn);
                List list = db.getListByRS(rs);
                int size = list.size();
                HashMap newlist = new HashMap();
                if (list != null && size > 0) {
                    HashMap h = (HashMap) list.get(0);
                    String temp = (String) h.get("occupation");
                    Vector newv = new Vector();
                    newlist.put(temp, newv);
                    for (int i = 0; i < size; i++) {
                        h = (HashMap) list.get(i);
                        String occ = (String) h.get("occupation");
                        if (temp.equals(occ)) {
                            newv.add( (String) h.get("username"));

                        } else {
                            temp = occ;
                            newv = new Vector();
                            newv.add( (String) h.get("username"));
                            newlist.put(temp, newv);
                        }
                    }
                }

              for (Iterator it = newlist.keySet().iterator();it.hasNext();) {
                  String key = (String)it.next();
                  Vector vt = (Vector)newlist.get(key);
                  System.out.println(key+" :");
                  for (int i=0;i<vt.size();i++) {
                      System.out.println(vt.get(i));
                  }
              }

            } catch (Exception ex) {
                ex.printStackTrace();

            }finally {
                try {
                    if (conn != null) {
                        conn.close();
                    }
                }catch (Exception e){}
            }

        }

  • 相关阅读:
    C#中的多态
    一个JQUERY文件
    等比例缩放图片
    WIN7 环境下 VS2012 打开某些解决方案项目 提示 【已停止工作】 解决办法
    统计字符串中字符出现的次数
    LINQ关联表查询语法和.NET扩展方法和JSON.NET时间格式化代码段
    EasyUI表格datagrid合并行单元格
    一个导出Excel的类
    一个缩略图的类
    分布式缓存MemCache
  • 原文地址:https://www.cnblogs.com/QDuck/p/413642.html
Copyright © 2011-2022 走看看