How to create a temp file in java without the random number appended to the filename?
I need to create a temp file, so I tried this: String[] TempFiles = {"c1234c10","c1234c11","c1234c12","c1234c13"}; for (int i = 0; i <= 3; i++) { try { String tempFile = TempFiles[i]; File temp = File.createTempFile(tempFile, ".xls"); System.out.println("Temp file : " + temp.getAbsolutePath()); } catch (IOException e) { e.printStackTrace(); } } The output is something like this: Temp file : C:\Users\MD1000\AppData\Local\Temp\c1234c108415816200650069233.xls Temp file : C:\Users\MD1000\AppData\Local\Temp\c1234c113748833645638701089.xls Temp file : C:\Users\MD1000\AppData\Local\Temp