/** * Initializes all the internal file and directory elements from the given output file. This method only must be * called if the product writer should write the given data to raw data files without calling of writeProductNodes. * This may be at the time when a dimap product was opened and the data should be continuously changed in the same * product file without an previous call to the saveProductNodes to this product writer. * * @param outputFile the dimap header file location. * @throws java.io.IOException if an I/O error occurs */ public void initDirs(final File outputFile) throws IOException { this.outputFile = FileUtils.ensureExtension(outputFile, DimapProductConstants.DIMAP_HEADER_FILE_EXTENSION); Debug.assertNotNull(this.outputFile); // super.writeProductNodes should have checked this already outputDir = this.outputFile.getParentFile(); if (outputDir == null) { outputDir = new File("."); } dataOutputDir = createDataOutputDir(); dataOutputDir.mkdirs(); if (!dataOutputDir.exists()) { throw new IOException("failed to create data output directory: " + dataOutputDir.getPath()); /*I18N*/ } }
return file; return new File(ensureExtension(path, extension));
String innerImgZipPath = FileUtils.ensureExtension(innerHdrZipPath, EnviConstants.IMG_EXTENSION); final Enumeration<? extends ZipEntry> enumeration = productZip.entries();
@Override public File getProductFile() { if (!ENVISAT_FORMAT_NAME.equals(getFormatName())) { return super.getProductFile(); } final String productName = getProductName(); return new File(getProductDir(), FileUtils.ensureExtension(productName, ".N1")); }
@Override public void actionPerformed(ActionEvent event) { JFileChooser fileChooser = new JFileChooser(); final FileNameExtensionFilter parameterFileFilter = createParameterFileFilter(); fileChooser.addChoosableFileFilter(parameterFileFilter); fileChooser.setFileFilter(parameterFileFilter); fileChooser.setDialogTitle(TITLE); fileChooser.setDialogType(JFileChooser.SAVE_DIALOG); applyCurrentDirectory(fileChooser); int response = fileChooser.showDialog(parentComponent, "Save"); if (JFileChooser.APPROVE_OPTION == response) { try { preserveCurrentDirectory(fileChooser); File selectedFile = fileChooser.getSelectedFile(); selectedFile = FileUtils.ensureExtension(selectedFile, "." + parameterFileFilter.getExtensions()[0]); String xmlString = parameterSupport.toDomElement().toXml(); writeToFile(xmlString, selectedFile); } catch (Exception e) { Debug.trace(e); JOptionPane.showMessageDialog(parentComponent, "Could not save parameters.\n" + e.getMessage(), TITLE, JOptionPane.ERROR_MESSAGE); } } }
public void testEnsureExtension_FileParameter() { File dirFile = new File("dir.with.dots"); File current = FileUtils.ensureExtension(new File(dirFile, "file.smc"), ".kdt"); assertEquals(GlobalTestTools.createPlatformIndependentFilePath("dir.with.dots/file.smc.kdt"), current.toString()); current = FileUtils.ensureExtension(new File(dirFile, "file."), ".kdt"); assertEquals(GlobalTestTools.createPlatformIndependentFilePath("dir.with.dots/file.kdt"), current.toString()); current = FileUtils.ensureExtension(new File(dirFile, "file"), ".kdt"); assertEquals(GlobalTestTools.createPlatformIndependentFilePath("dir.with.dots/file.kdt"), current.toString()); }
if (fileChooser.getFileFilter() instanceof BeamFileFilter) { BeamFileFilter fileFilter = (BeamFileFilter) fileChooser.getFileFilter(); file = FileUtils.ensureExtension(file, fileFilter.getDefaultExtension());
file = FileUtils.ensureExtension(file, ".xml"); writeXml(file, document);
return; final File absoluteFile = FileUtils.ensureExtension(file.getAbsoluteFile(), GCP_FILE_EXTENSION); String lastDirPath = absoluteFile.getParent(); visatApp.getPreferences().setPropertyString(GCP_EXPORT_DIR_PREFERENCES_KEY, lastDirPath);
public void testEnsureExtension_StringParameter() { assertEquals(GlobalTestTools.createPlatformIndependentFilePath("dir.with.dots/file.smc.kdt"), FileUtils.ensureExtension( GlobalTestTools.createPlatformIndependentFilePath("dir.with.dots/file.smc"), ".kdt")); assertEquals(GlobalTestTools.createPlatformIndependentFilePath("dir.with.dots/file.kdt"), FileUtils.ensureExtension( GlobalTestTools.createPlatformIndependentFilePath("dir.with.dots/file."), ".kdt")); assertEquals(GlobalTestTools.createPlatformIndependentFilePath("dir.with.dots/file.kdt"), FileUtils.ensureExtension(GlobalTestTools.createPlatformIndependentFilePath("dir.with.dots/file"), ".kdt")); }
@Override protected void writeProductNodesImpl() throws IOException { outputFile = null; final File file; if (getOutput() instanceof String) { file = new File((String) getOutput()); } else { file = (File) getOutput(); } outputFile = FileUtils.ensureExtension(file, Constants.FILE_EXTENSIONS[0]); deleteOutput(); updateProductName(); updateTilingParameter(); imageWriter = getTiffImageWriter(); outputStream = new FileImageOutputStream(outputFile); imageWriter.setOutput(outputStream); }
void exportPlacemarkDataTable() { final BeamFileChooser fileChooser = new BeamFileChooser(); fileChooser.setDialogTitle(MessageFormat.format("Export {0} Data Table", /*I18N*/ StringUtils.firstLetterUp(placemarkDescriptor.getRoleLabel()))); setComponentName(fileChooser, "Export_Data_Table"); fileChooser.setFileFilter(PlacemarkIO.createTextFileFilter()); final File ioDir = getIODir(); fileChooser.setCurrentDirectory(ioDir); fileChooser.setSelectedFile(new File(ioDir, "Data")); int result = fileChooser.showSaveDialog(getPaneWindow()); if (result == JFileChooser.APPROVE_OPTION) { File file = fileChooser.getSelectedFile(); if (file != null) { if (!visatApp.promptForOverwrite(file)) { return; } setIODir(file.getAbsoluteFile().getParentFile()); file = FileUtils.ensureExtension(file, PlacemarkIO.FILE_EXTENSION_FLAT_TEXT); try { try (Writer writer = new FileWriter(file)) { writePlacemarkDataTableText(writer); } } catch (IOException ignored) { showErrorDialog(MessageFormat.format("I/O Error.\nFailed to export {0} data table.", /*I18N*/ placemarkDescriptor.getRoleLabel())); } } } }
/** * Writes the in-memory representation of a data product. This method was called by <code>writeProductNodes(product, * output)</code> of the AbstractProductWriter. * * @throws IllegalArgumentException if <code>output</code> type is not one of the supported output sources. * @throws java.io.IOException if an I/O error occurs */ @Override protected void writeProductNodesImpl() throws IOException { outputFile = null; outputStream = null; bandWriter = null; final File file; if (getOutput() instanceof String) { file = new File((String) getOutput()); } else { file = (File) getOutput(); } outputFile = FileUtils.ensureExtension(file, GeoTiffProductWriterPlugIn.GEOTIFF_FILE_EXTENSION[0]); deleteOutput(); ensureNamingConvention(); writeGeoTIFFProduct(new FileImageOutputStream(outputFile), getSourceProduct()); }
return; file = FileUtils.ensureExtension(file, FILE_EXTENSION); try { final ColorPaletteDef colorPaletteDef = imageInfo.getColorPaletteDef();
String fileExtension = FileUtils.getExtension(file); if (fileExtension == null || !StringUtils.contains(beamFileFilter.getExtensions(), fileExtension)) { file = FileUtils.ensureExtension(file, beamFileFilter.getDefaultExtension());
_outputFile = FileUtils.ensureExtension(_outputFile, Hdf5ProductWriterPlugIn.HDF5_FILE_EXTENSION);