Here you can find the source of getDeckNameFromFile(final Path deckFile)
public static String getDeckNameFromFile(final Path deckFile)
//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; } } }