Java Temp File Create getTempFileGivenName(File file)

Here you can find the source of getTempFileGivenName(File file)

Description

Method getTempFileGivenName

License

Open Source License

Parameter

Parameter Description
file File

Return

String

Declaration

public static String getTempFileGivenName(File file) 

Method Source Code


//package com.java2s;
import java.io.File;

public class Main {
    /**/*from  ww  w .j  av a2  s .co  m*/
     * Field GIVEN_NAME_SUFFIX<br>
     * (value is "".mpw."")
     */
    private static final String GIVEN_NAME_SUFFIX = ".mpw.";

    /**
     * Method getTempFileGivenName
     * @param file File
     * @return String
     */
    public static String getTempFileGivenName(File file) {
        String fileName = file.getName();
        int index = fileName.indexOf(GIVEN_NAME_SUFFIX);

        if (index < 0) {
            return fileName;
        } else {
            return fileName.substring(0, index);
        }
    }
}

Related

  1. getTempFile(String filePrefix, boolean deleteOnExit)
  2. getTempFile(String name)
  3. getTempFile(String tmpdir)
  4. getTempFileDir()
  5. getTempFileFor(File file)
  6. getTempFileName()
  7. getTempFileName()
  8. getTempFileName(String base, String ext)
  9. getTempFileName(String fileExt)