List of utility methods to do Random File
String | getRandomFile(String dir) Get a random file from a directory. File directory = new File(dir); int count = 0; String randomFileName = ""; if (directory.exists()) { File[] listFiles = directory.listFiles(); int numFiles = listFiles.length; Random rand = new Random(System.currentTimeMillis()); int index = rand.nextInt(numFiles - 1); ... |
String | getRandomFile(String testName) get Random File File parent = getTestDir(); File result = new File(parent, getRandomFileName(testName)); return result.getCanonicalPath(); |
String | getRandomFilename(String filePath) get Random Filename return getRandomFilename(filePath, "tmp"); |
String | getRandomFilename(String prefix, String sufix) Returns the unique filename. Random random = new Random(); int n = random.nextInt(); String res = prefix + Math.abs(n) + sufix; File file = new File(res); if (file.exists()) return getRandomFilename(prefix, sufix); else return res; ... |
File | getRandomFilenameInDirectory(File rootFolder) get Random Filename In Directory String fileName = "rndFile-" + System.currentTimeMillis() + "-" + Math.abs(randomGen.nextInt()) + ".dat"; File newRandomFile = new File(rootFolder, fileName); return newRandomFile; |