Example usage for java.io File getName

List of usage examples for java.io File getName

Introduction

In this page you can find the example usage for java.io File getName.

Prototype

public String getName() 

Source Link

Document

Returns the name of the file or directory denoted by this abstract pathname.

Usage

From source file:Main.java

public static List<String> getAllSkinZipFiles(String path) {
    List<String> zipFiles = new ArrayList<String>();
    File file = new File(path);
    if (file.exists()) {
        File[] files = file.listFiles();
        if (files.length > 0) {
            for (File f : files) {
                if (f.getName().startsWith("skin") && f.getName().endsWith("zip")) {
                    zipFiles.add(f.getAbsolutePath());
                }//from  w  w  w . j  a va  2  s. c o m
            }
        }
    }
    return zipFiles;
}

From source file:Main.java

public static String toFileType(File file) {
    return toTypePart(file.getName());
}

From source file:Main.java

public static boolean isSupportedMultipleFormat(File file) {
    return isSupportedMultipleFormat(file.getName());
}

From source file:Main.java

private static void readGpxDirectory(File dir, final Map<String, Long> map, String parent,
        boolean absolutePath) {
    if (dir != null && dir.canRead()) {
        File[] files = dir.listFiles();
        if (files != null) {
            for (File f : files) {
                if (f.getName().toLowerCase().endsWith(".gpx")) { //$NON-NLS-1$
                    map.put(absolutePath ? f.getAbsolutePath() : parent + f.getName(), f.lastModified());
                } else if (f.isDirectory()) {
                    readGpxDirectory(f, map, parent + f.getName() + "/", absolutePath);
                }/*w  w  w  .j a  v a 2s  .co  m*/
            }
        }
    }
}

From source file:Main.java

public static String getFileName(String path) {
    String rst = null;/* w  ww .j a  v  a  2s . c o  m*/
    try {
        File f = new File(path);
        rst = f.getName();
    } catch (Exception e) {
        printE("OpusTool", e);
    }
    return rst;
}

From source file:Main.java

public static String getMIMEType(File var0) {
    String var1 = "";
    String var2 = var0.getName();
    String var3 = var2.substring(var2.lastIndexOf(".") + 1, var2.length()).toLowerCase();
    var1 = MimeTypeMap.getSingleton().getMimeTypeFromExtension(var3);
    return var1;
}

From source file:DirList.java

private static void listDirectories(File dir, String indent) {
    File[] dirs = dir.listFiles();
    for (File f : dirs) {
        if (f.isDirectory()) {
            System.out.println(indent + f.getName());
            listDirectories(f, indent + "  ");
        }//from w  w  w.  j a  v a  2s . com
    }
}

From source file:Main.java

/**
 * Return the extension portion of the file's name .
 * /*from   w  ww  .j  a v  a 2  s  .  c  om*/
 * @see #getExtension
 */
public static String getExtension(File f) {
    return (f != null) ? getExtension(f.getName()) : "";
}

From source file:Main.java

public static File saveImageFile(Component parent) {
    JFileChooser fileChooser = new JFileChooser();
    fileChooser.setFileFilter(new FileFilter() {
        @Override/*from ww  w  .j ava 2  s  . c o  m*/
        public String getDescription() {
            return "bmp";
        }

        @Override
        public boolean accept(File f) {
            String name = f.getName();
            boolean accepted = f.isDirectory() || name.endsWith(".bmp");
            return accepted;
        }
    });

    fileChooser.showSaveDialog(parent);
    return fileChooser.getSelectedFile();
}

From source file:Main.java

/**
 * Devuelve el nombre lindo de una pagina a partir
 * del path de la pagina (preferentemente el absoluto)
 * Ej: "MiPaginaConNombreLindo"/*from w  w  w. j ava2 s.c  o  m*/
 */
public static String getPageNiceName(String path) {
    File original = new File(path);
    String pageName = original.getName();
    pageName = pageName.substring(0, pageName.indexOf("."));
    return capitalize(pageName);
}