mysql设置唯一键

【一】设置字符唯一键(非自增)

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

【二】重命名为唯一键:

String fileName = FileUtil.renameToUUID(fname);

【三】获取文件后缀:

String fileType = fname.substring(fname.lastIndexOf(".") + 1, fname.length()).toLowerCase();

评论

暂无评论