Code example for File

Methods: listFiles

     * Similar to {@link File#listFiles()}, but returns a sorted set. 
     * Never returns {@code null}, instead a warning is logged, and an empty set is returned. 
    public static SortedSet<File> listFiles(File dir) {
        File[] files = dir.listFiles();
        if (files == null) {
            Log.w(TAG, "Failed to list children for " + dir.getPath());
            return new TreeSet<File>();
        return new TreeSet<File>(Arrays.asList(files));
    public static SortedSet<File> listMusicFiles(File dir) {
        SortedSet<File> files = listFiles(dir);
        Iterator<File> iterator = files.iterator();
        while (iterator.hasNext()) {
            File file =;
            if (!file.isDirectory() && !isMusicFile(file)) {
Experience pair programming with AI  Get Codota for Java