2019-07-15UID随机生成文件名

public class UuidUtil {

private UuidUtil(){}

public static String getUuid(){

return UUID.randomUUID().toString().replace("-","");

}

/**

    * 测试

    */

  public static void main(String[] args) {

System.out.println(UuidUtil.getUuid());

System.out.println(UuidUtil.getUuid());

System.out.println(UuidUtil.getUuid());

System.out.println(UuidUtil.getUuid());

}

}



String main = UuidUtil.getUuid();

取得文件的格式名例如.jpg:String ext = fileName.substring(fileName.lastIndexOf("."));

你可能感兴趣的:(2019-07-15UID随机生成文件名)