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

private static String getMimeType(File file) {
    String name = file.getName();
    int index = name.lastIndexOf(".");
    if (index == -1)
        return "*/*";
    return "application/" + name.substring(index + 1);
}

From source file:Main.java

/**
 * Gets the extension of a file.//from   w  ww .  j ava 2 s.  co m
 *
 * @param f the file
 * @return the extension of the file.
 */
public static String getExtension(File f) {
    return getExtension(f.getName());
}

From source file:Main.java

public static String getSavePicName(File cacheFile, String[] urls) {
    return "jiandan_" + cacheFile.getName().substring(0, 8) + "." + urls[urls.length - 1];
}

From source file:Main.java

public static String getSavePicName(File cacheFile, String[] urls) {
    return "jandan_" + cacheFile.getName().substring(0, 8) + "." + urls[urls.length - 1];
}

From source file:Main.java

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

From source file:Main.java

public static boolean isUnzippable(File path) {
    return (path.isFile() && path.canRead() && path.getName().endsWith(".zip"));
}

From source file:Main.java

public static String[] parseLanguages(File file) {
    String base = file.getName().substring(0, file.getName().indexOf('.'));
    int idx2 = base.lastIndexOf('_');
    int idx1 = base.lastIndexOf('_', idx2 - 1);
    String lng1 = base.substring(idx1 + 1, idx2);
    String lng2 = base.substring(idx2 + 1);
    return new String[] { lng1, lng2 };
}

From source file:Main.java

public static String GetMIMEType(File f) {
    String strSuffix = f.getName().substring(f.getName().lastIndexOf(".") + 1, f.getName().length())
            .toLowerCase();//from w w w  .j av  a 2s  .  c o  m

    if (strSuffix.equals("apk"))
        return "application/vnd.android.package-archive";
    else
        return "/*";
}

From source file:Main.java

public static String GetFileName(String path) {
    if (path == null)
        return "";
    if (path.trim().isEmpty())
        return "";
    File file = new File(path.trim());
    String v = file.getName();
    return v == null ? "" : v;
}

From source file:Main.java

private static void readGpxDirectory(File dir, final List<String> list, String parent) {
    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$
                    list.add(parent + f.getName());
                } else if (f.isDirectory()) {
                    readGpxDirectory(f, list, parent + f.getName() + "/");
                }//w  w  w.java2 s  .co m
            }
        }
    }
}