/** * Creates a file on the local FS. Pass size as {@link LocalDirAllocator.SIZE_UNKNOWN} if not * known apriori. We round-robin over the set of disks (via the configured dirs) and return a * file on the first path which has enough space. The file is guaranteed to go away when the JVM * exits. */ public File createTmpFileForWrite(String pathStr, long size, Configuration conf) throws IOException { // find an appropriate directory Path path = getLocalPathForWrite(pathStr, size, conf, true); File dir = new File(path.getParent().toUri().getPath()); String prefix = path.getName(); // create a temp file on this directory File result = File.createTempFile(prefix, null, dir); result.deleteOnExit(); return result; }