Java Path File Extention nio hasExtensionIgnoreCase(Path path, String ext)

Here you can find the source of hasExtensionIgnoreCase(Path path, String ext)

Description

has Extension Ignore Case

License

Open Source License

Declaration

public static boolean hasExtensionIgnoreCase(Path path, String ext) 

Method Source Code

//package com.java2s;
/*******************************************************************************
* Copyright (c) 2013, 2014 ETAS GmbH./*from   www.j av a 2 s  .c om*/
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Dennis Eder (ETAS GmbH) - initial API and implementation and/or initial documentation
*******************************************************************************/

import java.nio.file.Path;

public class Main {
    public static boolean hasExtensionIgnoreCase(Path path, String ext) {
        String name = path.getFileName().toString();
        int dot = name.lastIndexOf('.');
        String token = name.substring(dot + 1);
        if (token == null)
            return false;
        return token.equalsIgnoreCase(ext);
    }
}

Related

  1. getFullNameWithoutExtension(Path f)
  2. getLeafName(Path path, boolean includeExtension)
  3. getListOfFilesByExtension(Path directoryPath, Set extensions)
  4. getPath(String outputDir, String qualifiedFilename, String fileextension)
  5. getTransformedOutputPath(Path input, String compressExtension, String outputDir)
  6. insertSuffixBeforeExtension(String path, String suffix)
  7. listFile(final String path, final String extension)
  8. listFiles(final Path path, final String... extensions)
  9. listFiles(String path, String extension)