Java Temp File Create getTempFile(File parent, String fileName)

Here you can find the source of getTempFile(File parent, String fileName)

Description

Getting a temp file object in the directory in temporal directory which is referrenced by System.getProperty("java.io.tmpdir") .

License

Open Source License

Parameter

Parameter Description
parent a parameter
fileName a parameter

Declaration

public static File getTempFile(File parent, String fileName) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.File;

public class Main {
    /**/*w  w  w. ja  va2  s.c  o m*/
     * Getting a temp file object in the directory in temporal directory which is
     * referrenced by {@code System.getProperty("java.io.tmpdir")}.
     * @param parent
     * @param fileName
     *
     * @return
     */
    public static File getTempFile(File parent, String fileName) {
        return new File(new File(getTempDirectory(), parent.getPath()), fileName);
    }

    /**
     * Getting a temp file object in the temporal directory which is referrenced by
     * {@code System.getProperty("java.io.tmpdir")}.
     *
     * @param fileName
     * @return
     */
    public static File getTempFile(String fileName) {
        return new File(getTempDirectory(), fileName);
    }

    /**
     * Getting a temp file object of the temporal directory which is referrenced by
     * {@code System.getProperty("java.io.tmpdir")}.
     *
     * @return
     */
    public static File getTempDirectory() {
        return new File(getTempDirectoryPathString());

    }

    /**
     * Getting a string object of the temporal directory which is referrenced by
     * {@code System.getProperty("java.io.tmpdir")}.
     *
     * @return
     */
    public static String getTempDirectoryPathString() {
        return System.getProperty("java.io.tmpdir");
    }
}

Related

  1. createTempFile(final String file, final String ext)
  2. createTempFile(String oriFileName)
  3. getTempFile()
  4. getTempFile()
  5. getTempFile(File file)
  6. getTempFile(final File stackFile)
  7. getTempFile(final String directory, final String suffix, boolean autodelete)
  8. getTempFile(final String name)
  9. getTempFile(String config)