mass java function

      
      
private static FileFilter fileFilter = new FileFilter(){ public boolean accept(File pathname) { String tmp = pathname.getName().toLowerCase(); // if(pathname.isDirectory()) { // return false; // } if(tmp.endsWith(".xml")){ return true ; } return false ; } }; public static void main(String[] args) { // TODO Auto-generated method stub try { /* * * ?б */ // ArrayList at2 = MultiDesign.getAllCategory(); File myDir; File[] contents; Vector < File > vectorList = new Vector < File > (); Iterator currentFileView; File currentFile; String path; path = " d://MioPath// " ; myDir = new File(path); // vectorList.clear(); contents = myDir.listFiles(fileFilter); System. out .println(contents.length); // ?·? for(int i=0;i<contents.length;i++){ vectorList.add(contents[i]); } currentFileView = vectorList.iterator(); while (currentFileView.hasNext()){ currentFile = (File)currentFileView.next(); System. out .println(currentFile.getName() + " : " + currentFile.isDirectory()); if (currentFile.getName().equals( " dddd.xml " )){ currentFile.delete(); } } // ClassLoader.getSystemResource(name); } catch (Exception e) { e.printStackTrace(); } } public static Vector queryData(String query_str) throws SQLException { String sql = "" ; ResultSet rs = null ; PreparedStatement pst = null ; Connection con = DBManage.getConn(); con.setAutoCommit( false ); int colCount = 0 ; int rowCount = 0 ; String colNames[]; String tableData[][] = null ; Vector vectorList = new Vector(); con.setAutoCommit( false ); int rtnID = 0 ; try { if (query_str.toUpperCase().startsWith( " SELECT " )){ // sql = "select * from MIO_category_lang"; sql = query_str; pst = con.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE , ResultSet.CONCUR_READ_ONLY); rs = pst.executeQuery(); // prints the column names ResultSetMetaData metaData = rs.getMetaData(); colCount = metaData.getColumnCount(); rs.last(); rowCount = rs.getRow(); rs.beforeFirst(); // colNames = new String[colCount]; tableData = new String[rowCount][colCount]; for ( int i = 1 ; i <= colCount; i ++ ) { colNames[i - 1 ] = metaData.getColumnLabel(i); } int j = 0 ; // print out the records while (rs.next()) { for ( int i = 1 ; i <= colCount; i ++ ) { try { tableData[j][i - 1 ] = rs.getString(i); } catch (Exception e){e.printStackTrace();} } j ++ ; } vectorList.add(colNames); vectorList.add(tableData); } else { // update or insert sql = query_str; pst = con.prepareStatement(sql); rtnID = pst.executeUpdate(); con.commit(); vectorList.add(rtnID); } } catch (Exception e){ e.printStackTrace(); } if (pst != null ) pst.close(); if (con != null ) con.close(); if (rs != null ) rs.close(); return vectorList; }
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值