Java Path File List nio isPlaylistFile(Path testFile)

Here you can find the source of isPlaylistFile(Path testFile)

Description

is Playlist File

License

Open Source License

Declaration

public static boolean isPlaylistFile(Path testFile) 

Method Source Code

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

import java.nio.file.Files;
import java.nio.file.Path;

public class Main {
    private static String[] playlistExtStrings = new String[] { "m3u" };

    public static boolean isPlaylistFile(Path testFile) {
        String fileName = testFile.getFileName().toString();

        if (!Files.exists(testFile)) {
            return false;

        } else if (!Files.isRegularFile(testFile)) {
            return false;

        } else if (fileName.lastIndexOf(".") == -1 || fileName.lastIndexOf(".") == 0) {
            return false;

        }//  w  w  w .java2s  .c  o  m

        String testExtension = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();

        for (String playlistExtension : playlistExtStrings) {
            if (playlistExtension.toLowerCase().equals(testExtension)) {
                return true;
            }
        }

        return false;
    }
}

Related

  1. getDirectoryList(Path basePath)
  2. getPreorderList(Path root)
  3. getSortedPathList(final Path dir, final boolean dirsFirst)
  4. getTables(final List d1)
  5. isBlackListedDirectory(Path path)
  6. list(final Path directory)
  7. list(Path basePath)
  8. listChildren(Path dir)
  9. listChildren(Path dir, boolean searchDirectory)