Here you can find the source of getRandomFilename(String filePath)
public static String getRandomFilename(String filePath)
//package com.java2s; /**/*ww w. j ava2s . c o m*/ * * Copyright (c) 2015 Fannie Mae, All rights reserved. * This program and the accompany materials are made available under * the terms of the Fannie Mae Open Source Licensing Project available * at https://github.com/FannieMaeOpenSource/ezPie/wiki/License * * ezPIE? is a registered trademark of Fannie Mae * */ import java.io.File; import java.util.UUID; public class Main { public static String getRandomFilename(String filePath) { return getRandomFilename(filePath, "tmp"); } public static String getRandomFilename(String filePath, String extension) { String randomGuid = UUID.randomUUID().toString().replace("-", ""); String directory = filePath; if (!directory.endsWith(File.separator)) { directory += File.separator; } if ((extension != null) && extension.startsWith(".") && (extension.length() > 1)) { extension = extension.substring(1); } return String.format("%s%s.%s", directory, randomGuid, extension); } }