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

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

Introduction

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

Prototype

public static String getExtension(String filename) 

Source Link

Document

Gets the extension of a filename.

Usage

From source file:abfab3d.io.input.MeshReader.java

public MeshReader(String path) {
    m_path = path;
    m_format = FilenameUtils.getExtension(path);
}

From source file:com.jcalvopinam.core.Zipping.java

/***
 *
 * @param path path of file to core//from w  w w.  ja va2s .  com
 * @param fileSize size for each file in MB
 */
public Zipping(String path, int fileSize) throws IOException {
    CustomFile customFile = new CustomFile();
    File inputFile = new File(path);

    customFile.setPath(String.format("%s%s", inputFile.getParent(), File.separator));
    customFile.setFileName(FilenameUtils.getBaseName(inputFile.getName()));
    customFile.setFileNameExtension(inputFile.getName());
    customFile.setFileExtension(FilenameUtils.getExtension(inputFile.getName()));

    int bufferSize = CustomFile.BYTE_SIZE * CustomFile.BYTE_SIZE * fileSize;
    splitAndZipFile(inputFile, bufferSize, customFile);
}

From source file:mp1.include.me.Sabsalon1.java

private static String readFile(String filelocation)
        throws wrongFileNameException, FileNotFoundException, IOException {
    String ext = FilenameUtils.getExtension(filelocation);
    if ("c".equals(ext) || "C".equals(ext) || "cpp".equals(ext)) {
        BufferedReader buff = null;
        try {//w w  w . ja v a 2 s .  c o  m
            String sCurrentLine;
            buff = new BufferedReader(new FileReader(filelocation));
            while ((sCurrentLine = buff.readLine()) != null) {
                System.out.println(sCurrentLine);
                insidefile.add(sCurrentLine);
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if (buff != null)
                    buff.close();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    }

    else {
        throw new wrongFileNameException("Is not a valid file (must be a c/cpp file)");
    }

    return "unfinished";
}

From source file:com.jaeksoft.searchlib.streamlimiter.StreamLimiterString.java

public StreamLimiterString(String text, long limit, String fileName, String url) throws IOException {
    super(limit, fileName, url);
    this.text = text;
    this.extension = fileName != null ? FilenameUtils.getExtension(fileName) : null;
}

From source file:com.chinalbs.service.impl.FileServiceImpl.java

@Override
public String saveImage(MultipartFile[] multipartFile) {
    String webPath = null;// www.ja v  a 2  s  . c  o m
    if (multipartFile == null || multipartFile.length == 0) {
        return null;
    }
    try {
        for (MultipartFile multiFile : multipartFile) {
            if (multiFile.getSize() > ImageMaxSize) {
                continue;
            }
            String uuid = UUID.randomUUID().toString();
            String sourcePath = uploadPath + File.separator + "src_" + uuid + "."
                    + FilenameUtils.getExtension(multiFile.getOriginalFilename());
            //            webPath = uuid + "." + DEST_EXTENSION;
            webPath = File.separator + "src_" + uuid + "."
                    + FilenameUtils.getExtension(multiFile.getOriginalFilename());
            String storePath = uploadPath + File.separator + uuid + "." + DEST_EXTENSION;
            ;

            File tempFile = new File(System.getProperty("java.io.tmpdir") + File.separator + "upload_"
                    + UUID.randomUUID() + ".tmp");
            if (!tempFile.getParentFile().exists()) {
                tempFile.getParentFile().mkdirs();
            }

            multiFile.transferTo(tempFile);
            proccessImage(tempFile, sourcePath, storePath, licenseImageWidth, licenseImageHeight, true);
        }
    } catch (IllegalStateException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    return webPath;
}

From source file:Importers.ExcelImporter.java

@Override
public boolean isValid(File file) {
    String ext = FilenameUtils.getExtension(file.getAbsolutePath());
    if (ext.equalsIgnoreCase("xls")) {
        return true;
    }//from  w w w  .  j ava 2s.c om
    return false;
}

From source file:com.yahoo.maven.visitor.SuccessfulCompilationAsserter.java

public void assertNoCompilationErrors() throws IOException {
    JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
    DiagnosticCollector<JavaFileObject> diagnostics = new DiagnosticCollector<>();
    try (StandardJavaFileManager fileManager = compiler.getStandardFileManager(diagnostics, null,
            StandardCharsets.UTF_8)) {
        List<File> javaFiles = new ArrayList<>();
        try (Stream<Path> stream = Files.walk(scratchSpace)) {
            Iterator<Path> iterator = stream.iterator();
            while (iterator.hasNext()) {
                Path path = iterator.next();
                if (Files.isRegularFile(path) && "java".equals(FilenameUtils.getExtension(path.toString()))) {
                    javaFiles.add(path.toFile());
                }/*ww  w  . ja  v a 2 s .  c o  m*/
            }
        }
        Iterable<? extends JavaFileObject> compilationUnits = fileManager
                .getJavaFileObjectsFromFiles(javaFiles);
        compiler.getTask(null, fileManager, diagnostics,
                Arrays.asList("-classpath", System.getProperty("java.class.path")), null, compilationUnits)
                .call();
    }
    int errors = 0;
    for (Diagnostic<? extends JavaFileObject> diagnostic : diagnostics.getDiagnostics()) {
        if (Diagnostic.Kind.ERROR.equals(diagnostic.getKind())) {
            System.err.println(diagnostic);
            errors++;
        }
    }
    assertEquals(0, errors);
}

From source file:net.sourceforge.javydreamercsw.validation.manager.web.file.PDFDisplay.java

@Override
public boolean supportFile(String name) {
    return FilenameUtils.getExtension(name).equals("pdf");
}

From source file:com.jaeksoft.searchlib.streamlimiter.StreamLimiterBase64.java

public StreamLimiterBase64(String base64text, int limit, String fileName) throws IOException {
    super(limit, fileName, null);
    this.base64text = base64text;
    this.extension = fileName != null ? FilenameUtils.getExtension(fileName) : null;
}

From source file:ch.cyberduck.core.udt.qloudsonic.QloudsonicVoucherFinder.java

public QloudsonicVoucherFinder() {
    super(LocalFactory.get(PreferencesFactory.get().getProperty("application.support.path")),
            new Filter<Local>() {
                @Override/*from  ww w .  ja  v a 2s.co m*/
                public boolean accept(final Local file) {
                    return "qloudsonicvoucher".equals(FilenameUtils.getExtension(file.getName()));
                }

                @Override
                public Pattern toPattern() {
                    return Pattern.compile("qloudsonicvoucher");
                }
            });
}