• 一个使用矢量的例子!


        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){}
            }

        }

  • 相关阅读:
    Template、ItemsPanel、ItemContainerStyle、ItemTemplate(包括ListBox的Item子项是横向排列)
    特殊字符处理(WPF)
    DataGrid的组成论述(WPF)
    DataGrid合并单元格(wpf)
    WPF各种控件详解——(WPF从我炫系列)
    C# WPF DataGrid 隔行变色及内容居中对齐
    WPF中的事件及冒泡事件和隧道事件(预览事件)的区别
    迭代式返回 IEnumerable<T>
    react className 样式控制
    React setState更新数组中的某个元素Element item
  • 原文地址:https://www.cnblogs.com/QDuck/p/413642.html
Copyright © 2020-2023  润新知