Example usage for org.apache.commons.io FilenameUtils removeExtension

List of usage examples for org.apache.commons.io FilenameUtils removeExtension

Introduction

In this page you can find the example usage for org.apache.commons.io FilenameUtils removeExtension.

Prototype

public static String removeExtension(String filename) 

Source Link

Document

Removes the extension from a filename.

Usage

From source file:com.itemanalysis.jmetrik.data.DataTableName.java

@Override
public String toString() {
    return FilenameUtils.removeExtension(dataFile.getName());
}

From source file:com.util.StringUtilities.java

/**
 * Builds out the filename for the attachment. order is...
 * [emailID_number_base.extension]/*from w w w .  j a  v a2s  .  c  o  m*/
 *
 * @param filename String
 * @param emailID Integer
 * @param attachmentNumber Integer
 * @return
 */
public static String properAttachmentName(String filename, int emailID, int attachmentNumber) {
    String base = FilenameUtils.removeExtension(filename).replace("[^A-Za-z0-9]", "_");
    String extension = FilenameUtils.getExtension(filename);
    String number = String.valueOf(attachmentNumber);
    if (attachmentNumber < 10) {
        number = "0" + number;
    }
    return emailID + "_" + number + "_" + base + "." + extension;
}

From source file:modmanager.ArchiveExtractor.java

@Override
protected Response doInBackground() {
    Response res = Response.SUCCESS;

    boolean somethingInstalled = false;

    for (File zipfile : zipfiles) {
        File destinationDirectory = new File(modmanager.getModificationDirectory(),
                FilenameUtils.removeExtension(zipfile.getName()));

        if (destinationDirectory.exists()) {
            res = Response.SUCCESS_WITH_ERRORS;
            continue;
        } else {//from   w  w w . j  a  v a  2  s . c o  m
            destinationDirectory.mkdirs();
        }

        try {

            unzipper.unzip(zipfile, destinationDirectory, new UnzipUtility.ProgressListener() {

                @Override
                public void progress(String file, int index, int max_count) {
                    publish(file);
                    setProgress((int) ((float) index / max_count * 100f));
                }
            });

            somethingInstalled = true;
        } catch (IOException | SevenZipException ex) {
            logger.log(Level.SEVERE, ex.getMessage());

            destinationDirectory.delete();

            return Response.SUCCESS_WITH_ERRORS;
        }
    }

    return somethingInstalled ? res : Response.NO_CHANGE;
}

From source file:neembuu.uploader.zip.generator.PluginToUpdate.java

/**
 * Get the name of the plugin./*  w  w  w.j a  v  a 2  s. co m*/
 * It is recovered from the file name.
 * @return Returns the name of the plugin.
 */
public String getName() {
    return FilenameUtils.removeExtension(file.getName());
}

From source file:net.sf.firemox.tools.Converter.java

/**
 * DCK format should be ://w  w w . j a va2s  .c  o m
 * <ul>
 * <li>;comment</li>
 * <li>...</li>
 * <li>...\t$number $card-name</li>
 * </ul>
 * 
 * @param directory
 *          the directory containing the files to translate.
 * @throws IOException
 *           If some other I/O error occurs
 */
public static void convertDCK(String directory) throws IOException {
    final File file = MToolKit.getFile(directory);
    if (!file.isDirectory()) {
        throw new RuntimeException("The given parameter should be a directory");
    }

    File[] list = file.listFiles((FileFilter) FileFilterUtils.suffixFileFilter("dck"));
    for (File fileI : list) {
        String fileName = FilenameUtils.removeExtension(fileI.getAbsolutePath()) + ".txt";
        FileOutputStream out = new FileOutputStream(fileName);
        InputStream in = new FileInputStream(fileI);
        BufferedReader bufIn = new BufferedReader(new InputStreamReader(in));
        PrintWriter bufOut = new PrintWriter(out);
        String line = null;
        while ((line = bufIn.readLine()) != null) {
            if (line.startsWith(";")) {
                // this is a comment
                bufOut.println("#" + line.substring(1));
            } else if (line.startsWith(".") && line.indexOf('\t') > 1) {
                // this is a line containing card definition
                line = line.substring(line.indexOf('\t') + 1).trim();
                int delim = line.indexOf('\t');
                String cardName = line.substring(delim + 1);
                cardName = cardName.replaceAll(" : ", "_").replaceAll(" :", "_").replaceAll(": ", "_")
                        .replaceAll(":", "_").replaceAll(" ", "_").replaceAll("'", "").replaceAll(",", "")
                        .replaceAll("-", "");
                bufOut.println(cardName + ";" + line.substring(0, delim));
            }
        }
        IOUtils.closeQuietly(bufOut);
        IOUtils.closeQuietly(bufIn);
    }
}

From source file:com.streamsets.pipeline.lib.el.FileEL.java

@ElFunction(prefix = "file", name = "removeExtension", description = "Returns path without the extension (e.g. '/path/file' from /path/file.txt).")
public static String removeExtension(@ElParam("filePath") String filePath) {
    if (isEmpty(filePath)) {
        return null;
    }/*from   w  ww .j  av a2s  .  c om*/

    return FilenameUtils.removeExtension(filePath);
}

From source file:de.uni_hildesheim.sse.ant.versionReplacement.FeatureVersionTask.java

@Override
// checkstyle: stop exception type check
protected void transformArtifact(File artifact) throws Exception {
    String name = FilenameUtils.removeExtension(artifact.getName());
    VersionReplacer.createFeature(artifact, getVersion(), new File(getDestinationFolder(), name + ".jar"));
}

From source file:net.rwx.maven.asciidoc.services.impl.RootServiceImpl.java

protected void setOutputPath(String inputPath, String extension) {
    StringBuilder builder = new StringBuilder();
    builder.append(FilenameUtils.removeExtension(inputPath));
    builder.append(extension);/*from   ww  w. j a v  a 2  s.  c  o  m*/

    setOutputPath(builder.toString());
}

From source file:edu.co.usbcali.ir.util.SgmToXmlConverter.java

public void generateXmlFromSgm(String path) {
    String xmlContent = "";
    String lineSeparator = System.getProperty("line.separator");

    try {//from  ww w  .  ja v a  2 s.c o  m
        File sgmFile = new File(path);
        try (FileReader reader = new FileReader(sgmFile)) {
            BufferedReader buffer = new BufferedReader(reader);

            String line;

            xmlContent += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + lineSeparator;
            xmlContent += "<collection>" + lineSeparator;

            while ((line = buffer.readLine()) != null) {
                if (!line.contains("<!DOCTYPE lewis SYSTEM \"lewis.dtd\">")) {
                    line = processCharactersInLine(line);
                    xmlContent += line + lineSeparator;
                }
            }

            xmlContent += "</collection>";
        }

        String xmlPath = FilenameUtils.removeExtension(sgmFile.getName()) + ".xml";

        WriteFile.writeFileContent(xmlContent, xmlPath);
    } catch (FileNotFoundException ex) {
        Logger.getLogger(SgmToXmlConverter.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IOException ex) {
        Logger.getLogger(SgmToXmlConverter.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:ch.unibas.fittingwizard.infrastructure.RealLRAScript.java

@Override
public LRAScriptOutput execute(LRAScriptInput input) {

    List<String> args = Arrays.asList("-in", input.getSdfFile().toString());

    File lPunFile = new File(FilenameUtils.removeExtension(input.getSdfFile().toString()) + LPunExtension);
    ScriptUtilities.deleteFileIfExists(lPunFile);

    runner.exec(lraScriptFile, args);// www. j  a  va2s.co m

    ScriptUtilities.verifyFileExistence(lPunFile);

    return new LRAScriptOutput(lPunFile);
}