/** * 獲取資料庫鏈結
* @param mdbpath 檔案路徑
* @return
*/private static connection getconn(string mdbpath) catch (classnotfoundexception e) catch (sqlexception e)
return conn;
}/**
* 建表
* @param mdbpath 資料庫檔案路徑
* @param types 型別
* @throws sqlexception
*/public static void createtable(string mdbpath,string... types) throws sqlexception
}conn.close();
}/**
* 獲取查詢資料
* @param mdbpath 檔案路徑
* @param sql 查詢語句
* @param column 查詢的列
* @return
* @throws exception
*/public static list> resolvermdb(string mdbpath,
string sql, object... column) throws exception
try ( connection conn = getconn(mdbpath);
statement statement = conn.createstatement();
resultset result = statement.executequery(sql))
entitylist.add(maplist);
} conn.close();
} catch (exception e)
return entitylist;
} /**
* 獲取所有表資料
* @param mdbpath 檔案路徑
* @return map>> map《表名,list《表資料》
*/public static map>> resolvermdb(string mdbpath) );
stmt = (statement) conn.createstatement();
while(tables.next())
entitylist.add(map);
// system.out.println();
} entitymap.put(tablename, entitylist);
}} catch (exception e) finally catch (sqlexception e)
}return entitymap;
}
java 檔案操作
複製檔案 param fromfilepath string 目標檔案 param tofilepath string 儲存檔案的路徑 return boolean 複製成功 true 出錯 false public static boolean copyfile string fromfilepa...
java 檔案操作
public class documentutil else else copyfinished this.copyfolder startfile,desfile return copyfinished 顯示目錄下所有檔案ming public static file getdocuments s...
Java 檔案操作
private jfilechooser chooser filenameextensionfilter filter new filenameextensionfilter allowed file txt jar chooser.setfilefilter filter intvalue cho...