List of usage examples for org.apache.commons.io FilenameUtils removeExtension
public static String removeExtension(String filename)
From source file:com.opendoorlogistics.components.reports.ReporterPanel.java
public ReporterPanel(final ComponentConfigurationEditorAPI api, final ReporterConfig config) { setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); // setAlignmentX(LEFT_ALIGNMENT); // add config panel ReporterConfigPanel configPanel = new ReporterConfigPanel(config); configPanel.setBorder(createBorder("Export and processing options")); add(configPanel);//from w w w. ja v a 2s . c om // add gap add(Box.createRigidArea(new Dimension(1, 10))); // add tools panel JPanel toolContainer = new JPanel(); toolContainer.setLayout(new BorderLayout()); toolContainer.setBorder(createBorder("Tools")); add(toolContainer); JPanel tools = new JPanel(); toolContainer.add(tools, BorderLayout.NORTH); toolContainer.setMaximumSize(new Dimension(Integer.MAX_VALUE, api.isInstruction() ? 120 : 80)); // tools.setLayout(new BoxLayout(tools, BoxLayout.X_AXIS)); tools.setLayout(new GridLayout(api == null || api.isInstruction() ? 2 : 1, 3)); JButton compileButton = new JButton("Compile .jrxml file"); compileButton.setToolTipText("Compile a JasperReports .jrxml file"); compileButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { File file = ReporterTools.chooseJRXMLFile(api.getComponentPreferences(), LAST_JRXML_TO_COMPILE, ReporterPanel.this); if (file == null) { return; } final ExecutionReport report = api.getApi().uiFactory().createExecutionReport(); try { JasperDesign design = JRXmlLoader.load(file); if (design == null) { throw new RuntimeException("File to load jrxml: " + file.getAbsolutePath()); } String filename = FilenameUtils.removeExtension(file.getAbsolutePath()) + ".jasper"; JasperCompileManager.compileReportToFile(design, filename); } catch (Throwable e2) { report.setFailed(e2); report.setFailed("Failed to compile file " + file.getAbsolutePath()); } finally { if (report.isFailed()) { Window window = SwingUtilities.getWindowAncestor(ReporterPanel.this); api.getApi().uiFactory() .createExecutionReportDialog( JFrame.class.isInstance(window) ? (JFrame) window : null, "Compiling jrxml file", report, true) .setVisible(true); } else { JOptionPane.showMessageDialog(ReporterPanel.this, "Compiled jxrml successfully: " + file.getAbsolutePath()); } } } }); tools.add(compileButton); for (final OrientationEnum orientation : new OrientationEnum[] { OrientationEnum.LANDSCAPE, OrientationEnum.PORTRAIT }) { // create export button JButton button = new JButton("Export " + orientation.getName().toLowerCase() + " template"); button.setToolTipText( "Export template (editable .jrxml and compiled .jasper) based on the input tables (" + orientation.getName().toLowerCase() + ")"); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ReporterTools.exportReportTemplate(api, config, orientation, ReporterPanel.this); } }); tools.add(button); // create view button if (api.isInstruction()) { final String title = "View basic " + orientation.getName().toLowerCase() + " report"; button = new JButton(title); button.setToolTipText("View basic report based on the input tables (" + orientation.getName().toLowerCase() + ")"); button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (api != null) { api.executeInPlace(title, orientation == OrientationEnum.LANDSCAPE ? ReporterComponent.VIEW_BASIC_LANDSCAPE : ReporterComponent.VIEW_BASIC_PORTRAIT); } } }); tools.add(button); } } }
From source file:ch.unibas.fittingwizard.infrastructure.RealExportScript.java
private File getLPunOutputFile(File exportFileName) { // for exmpale: fit_1_co2.pun --> fit_1_co2.lpun String name = FilenameUtils.removeExtension(exportFileName.getName()) + ".lpun"; File convertedFile = new File(outputDir, name); return convertedFile; }
From source file:com.aliyun.odps.ship.download.DshipDownload.java
public DshipDownload() { threads = Integer.parseInt(DshipContext.INSTANCE.get(Constants.THREADS)); if (DshipContext.INSTANCE.get(Constants.LIMIT) != null) { limit = Long.parseLong(DshipContext.INSTANCE.get(Constants.LIMIT)); } else {// w ww. j a va 2 s . c o m limit = null; } path = DshipContext.INSTANCE.get(Constants.RESUME_PATH); projectName = DshipContext.INSTANCE.get(Constants.TABLE_PROJECT); tableName = DshipContext.INSTANCE.get(Constants.TABLE); partitonSpecLiteral = DshipContext.INSTANCE.get(Constants.PARTITION_SPEC); ext = Files.getFileExtension(path); filename = Files.getNameWithoutExtension(path); parentDir = FilenameUtils.removeExtension(path) + File.separator; context = DshipContext.INSTANCE.getExecutionContext(); }
From source file:edu.ur.file.db.DefaultFileInfo.java
/** * The file name in the file system. If the * file name has an extension it is removed * //w ww .jav a 2 s . c o m * @param fileName * @throws IllegalFileSystemNameException */ void setName(String name) throws IllegalFileSystemNameException { List<Character> illegalCharacters = IllegalFileSystemNameException.nameHasIllegalCharacerter(name); if (illegalCharacters.size() > 0) { throw new IllegalFileSystemNameException(illegalCharacters, name); } this.name = FilenameUtils.removeExtension(name); }
From source file:eu.prestoprime.datamanagement.impl.P4DIP.java
@Override public List<URL> getFrames() throws P4IPException { P4PropertyManager properties = ConfigurationManager.getPropertyInstance(); String framesPath = this.getPubFolder() + File.separator + properties.getProperty(P4Property.P4_FRAMES_FOLDER); List<String> frames = Arrays.asList(new File(framesPath).list()); Collections.sort(frames, new Comparator<String>() { @Override/* www .j ava 2s. c o m*/ public int compare(String frame1, String frame2) { String frameName1 = FilenameUtils.removeExtension(frame1); String frameName2 = FilenameUtils.removeExtension(frame2); String nFrame1 = frameName1.split("F")[0]; String nFrame2 = frameName2.split("F")[0]; int key1 = Integer.parseInt(nFrame1); int key2 = Integer.parseInt(FilenameUtils.removeExtension(nFrame2)); return key1 - key2; } }); List<URL> urls = new ArrayList<>(); try { String p4URL = properties.getProperty(P4Property.P4_URL); String p4Storage = properties.getProperty(P4Property.P4_STORAGE_FOLDER); String p4Frames = properties.getProperty(P4Property.P4_FRAMES_FOLDER); for (String frame : frames) urls.add(new URL(p4URL + File.separator + p4Storage + File.separator + id + File.separator + p4Frames + File.separator + frame)); } catch (MalformedURLException e) { throw new P4IPException("Unable to create valid URL..."); } return urls; }
From source file:io.github.bluemarlin.ui.searchtree.SearchTreeItem.java
@Override public String toString() { return FilenameUtils.removeExtension(file.getName()); }
From source file:bs.java
private static void loadable(String filename) { File file = new File(filename); JarInputStream is;//from w w w . j av a 2s. c o m try { ClassLoader loader = URLClassLoader.newInstance(new URL[] { file.toURI().toURL() }); is = new JarInputStream(new FileInputStream(file)); JarEntry entry; while ((entry = is.getNextJarEntry()) != null) { if (entry.getName().endsWith(".class") && !entry.getName().contains("/")) { Class<?> cls = Class.forName(FilenameUtils.removeExtension(entry.getName()), false, loader); for (Class<?> i : cls.getInterfaces()) { if (i.equals(Loadable.class)) { Loadable l = (Loadable) cls.newInstance(); Bs.addModule(l); } } } } } catch (Exception e) { System.out.println(e.getMessage()); } }
From source file:com.splunk.shuttl.archiver.importexport.csv.CsvBucketCreatorTest.java
public void _givenCsvFile_bucketDirectoryHasSameNameAsCsvFileWithoutExtension() { Bucket csvBucket = csvBucketCreator.createBucketWithCsvFile(csvFile, bucket); File bucketDir = csvBucket.getDirectory(); String fileWithoutExtension = FilenameUtils.removeExtension(csvFile.getName()); assertEquals(fileWithoutExtension, bucketDir.getName()); }
From source file:com.mapr.ocr.text.ImageToText.java
public static void processFile(String fileName) { System.out.println("Processing file:" + fileName); File imageFile = new File(fileName); String resultText = null;/* w w w. j ava2 s . c o m*/ if (fileName.endsWith("pdf")) { resultText = processPDF(fileName); } else { resultText = processImageFile(fileName); } try { String rowKey = FilenameUtils .removeExtension(fileName.substring(fileName.lastIndexOf("/") + 1, fileName.length())); populateDataInMapRDB(config, convertedTable, rowKey, cf, "info", resultText); populateDataInMapRDB(config, convertedTable, rowKey, cf, "filepath", fileName); } catch (Exception ex) { ex.printStackTrace(); LOGGER.log(Level.SEVERE, "Exception processing file " + fileName + " " + ex); } LOGGER.info(resultText); }
From source file:com.itemanalysis.jmetrik.file.JmetrikOutputWriter.java
private void saveCsvFile(File outputFile, Outputter outputter) throws IOException { ArrayList<VariableAttributes> variables = outputter.getColumnAttributes(); LinkedHashMap<VariableName, VariableAttributes> variableAttributeMap = new LinkedHashMap<VariableName, VariableAttributes>(); String[] header = new String[variables.size()]; int hIndex = 0; for (VariableAttributes v : variables) { variableAttributeMap.put(v.getName(), v); header[hIndex] = v.getName().toString(); hIndex++;/* www .j av a 2 s. c om*/ } Writer writer = null; CSVPrinter printer = null; try { //Ensure that file is a csv file. String fname = FilenameUtils.removeExtension(outputFile.getAbsolutePath()); outputFile = new File(fname + ".csv"); writer = new OutputStreamWriter(new FileOutputStream(outputFile)); printer = new CSVPrinter(writer, CSVFormat.DEFAULT.withCommentMarker('#').withHeader(header)); Iterator<Object[][]> iter = outputter.iterator(); Object[][] outputChunk = null; while (iter.hasNext()) { outputChunk = iter.next(); for (int i = 0; i < outputChunk.length; i++) { printer.printRecord(outputChunk[i]); } } } catch (IOException ex) { throw ex; } finally { printer.close(); } }