mysql設置惟一鍵

【一】設置字符惟一鍵(非自增)

String uuid = UUID.randomUUID().toString().replace("-", "");
對象.setId(uuid);

【二】重命名爲惟一鍵:

String fileName = FileUtil.renameToUUID(fname);

【三】獲取文件後綴:

String fileType = fname.substring(fname.lastIndexOf(".") + 1, fname.length()).toLowerCase();
相關文章
相關標籤/搜索