Here you can find the source of getTempFileFor(File file)
Parameter | Description |
---|---|
file | file used for the name and location (it is not read or written). |
public static File getTempFileFor(File file)
//package com.java2s; //License from project: Apache License import java.io.File; public class Main { /**/*from ww w. j a v a2s . c om*/ * Find a non-existing file in the same directory using the same name as prefix. * * @param file file used for the name and location (it is not read or written). * @return a non-existing file in the same directory using the same name as prefix. */ public static File getTempFileFor(File file) { File parent = file.getParentFile(); String name = file.getName(); File result; int index = 0; do { result = new File(parent, name + "_" + index++); } while (result.exists()); return result; } }