Java Path File Name nio getDeckNameFromFile(final Path deckFile)

Here you can find the source of getDeckNameFromFile(final Path deckFile)

Description

Gets the name of a deck file without the extension.

License

Open Source License

Declaration

public static String getDeckNameFromFile(final Path deckFile) 

Method Source Code

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

import java.nio.file.Path;

public class Main {
    public static final String DECK_EXTENSION = ".dec";

    /**//from  w  w w . j  a va2  s .c  o  m
     * Gets the name of a deck file without the extension.
     */
    public static String getDeckNameFromFile(final Path deckFile) {
        return getDeckNameFromFilename(deckFile.getFileName().toString());
    }

    /**
     * Extracts the name of a deck from its filename.
     */
    public static String getDeckNameFromFilename(final String deckFilename) {
        if (deckFilename.indexOf(DECK_EXTENSION) > 0) {
            return deckFilename.substring(0, deckFilename.lastIndexOf(DECK_EXTENSION));
        } else {
            return deckFilename;
        }
    }
}

Related

  1. getConfigurationFile(String installPath, String serverName)
  2. getConfigurationFilePath(String name)
  3. getContentPath(Path zipFilePath, String contentFileName)
  4. getDatabaseDirectoryPath(String databaseDirectory, String name)
  5. getDataPath(String filename)
  6. getDefaultPathName(final String address, final long lspId)
  7. getDirectoryNames(Path baseDirectory)
  8. getFileContent(String fileNameOrPath)
  9. getFileInFolder(Path p, String filename)