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:info.magnolia.importexport.BootstrapFilesComparator.java

private static String getName(File file) {
    String name = StringUtils.substringBeforeLast(file.getName(), ".");
    if (name.endsWith(DataTransporter.XML) || name.endsWith(DataTransporter.PROPERTIES)) {
        name = StringUtils.substringBeforeLast(file.getName(), ".");
    }//  w w  w .j  a v  a  2  s . co m
    return name;
}

From source file:Main.java

public static void compressDir(File file) throws IOException {
    FileOutputStream f = new FileOutputStream(file.getParent() + file.getName() + ".zip");
    CheckedOutputStream cs = new CheckedOutputStream(f, new Adler32());
    ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(cs));

    compressDir(file, out, file.getAbsolutePath());

    out.flush();/* w  w w  .java 2s .c o m*/
    out.close();
}

From source file:Main.java

/**
 * Devuelve el fully qualified name de UseCaseName a partir
 * del path de una pagina (preferentemente el absoluto)
 *///from   ww  w . j  a v  a 2s.  c o m
public static String getImportUseCaseName(String path) {
    File arch = new File(path);
    //legar hasta client: pages=>caso de uso=>useCases=>client
    File client = arch.getParentFile().getParentFile().getParentFile().getParentFile();
    return client.getParentFile().getName() + "." + client.getName() + "." + "UseCaseNames";
}

From source file:Main.java

/**
 * Copy a file./*w w  w  .j  av a2  s  . c  o  m*/
 * 
 * @param sourceFile
 *            The source
 * @param destDir
 *            The destination directory
 * @throws IOException
 *             Everything fails sometimes
 */
protected static void CopyFileToDir(File sourceFile, File destDir) throws IOException {

    File destFile = new File(destDir, sourceFile.getName());

    if (!destFile.exists()) {
        destFile.createNewFile();
    }

    FileChannel source = null;
    FileChannel destination = null;

    try {
        source = new FileInputStream(sourceFile).getChannel();
        destination = new FileOutputStream(destFile).getChannel();
        destination.transferFrom(source, 0, source.size());
    } finally {
        if (source != null) {
            source.close();
        }
        if (destination != null) {
            destination.close();
        }
    }
}

From source file:com.robin.testcase.ApkResigner.java

private static String getReSignedAutName(final File autFile) {
    String autName = autFile.getName();
    String autFileCanonical = null;
    try {//from w w  w.j  ava 2  s  . co m
        autFileCanonical = autFile.getCanonicalPath();
    } catch (IOException e) {
        e.printStackTrace();
    }

    String newAutNameFolderPart = getUnderLinedPath(autFileCanonical);
    String newAutNameFileNamePart = FilenameUtils.getBaseName(autName);
    String newAutName = newAutNameFolderPart + "_" + newAutNameFileNamePart;
    String newAutNameWithExtension = newAutName + "_" + getAutVersion(autFile) + "."
            + FilenameUtils.getExtension(autName);
    return newAutNameWithExtension;
}

From source file:Main.java

public static Enumeration getAllFilesIn(File dir) {
    File[] files;//from   w ww . jav a  2  s  . co m
    if (dir.isDirectory()) {
        files = dir.listFiles(new FileFilter() {
            public boolean accept(File f) {
                if (f.isDirectory())
                    return false;
                return (f.getName().endsWith(".txt"));
            }
        });
        Arrays.sort(files);
    } else {
        files = new File[] { dir };
    }
    Vector vect = new Vector(files.length);
    for (int i = 0; i < files.length; ++i)
        vect.addElement(files[i]);
    return vect.elements();
}

From source file:com.anrisoftware.prefdialog.miscswing.filechoosers.FileFilterExtension.java

/**
 * Appends the file extension if the file does not have the extension
 * already./*from   w  w w  . j  av  a  2 s  .  c  o  m*/
 *
 * @param file
 *            the {@link File}.
 *
 * @param extension
 *            the {@link String} extension.
 *
 * @return the {@link File} with appended extension.
 */
public static File appendExtensionToFile(File file, String extension) {
    if (!isExtension(file.getName(), extension)) {
        file = new File(format("%s.%s", file.getAbsolutePath(), extension));
    }
    return file;
}

From source file:Main.java

public static void valiFileIsFile(File file) throws IllegalArgumentException {
    if (!file.isFile()) {
        throw new IllegalArgumentException("File:'" + file.getName() + "'does not exist or not file!");
    }/*from   w  ww .j a  v  a 2  s .  co m*/
}

From source file:biz.paluch.maven.configurator.FileTemplating.java

private static File getTargetFile(File next) {
    File parent = next.getParentFile();

    String filename = next.getName();
    filename = filename.replaceAll("\\.template", "");
    return new File(parent, filename);
}

From source file:com.starit.diamond.utils.AppNameUtils.java

private static File[] listFiles(File dir, final String suffix, final String[] excludes) {
    return dir.listFiles(new FileFilter() {
        public boolean accept(File file) {
            return !inExcludes(file, excludes) && file.getName().toLowerCase().endsWith(suffix);
        }//from w w  w.  j  ava 2 s. com
    });
}