public SourceMetadataFilenameFilter(String fileName) { this.fileName = fileName; this.wantedPrefix = FileUtils.getFilenameWithoutExtension(fileName) + "-"; }
/** * Returns the size of the Product in megabytes. * * @return the size in megabytes. */ public float getProductSize() { final File productFile = getProductFile(); final String extension = FileUtils.getExtension(productFile); long dirSize = 0; if (productFile.exists() && productFile.getParentFile() != null && DimapProductConstants.DIMAP_HEADER_FILE_EXTENSION.equals(extension)) { final File realtedDataDir = new File(productFile.getParentFile(), FileUtils.getFilenameWithoutExtension(productFile) + DimapProductConstants.DIMAP_DATA_DIRECTORY_EXTENSION); if (realtedDataDir.exists()) { final File[] files = realtedDataDir.listFiles(); for (int i = 0; i < files.length; i++) { dirSize += files[i].length(); } } } return (productFile.length() + dirSize) / (1024.0f * 1024.0f); }
@Override public void run() { FileUtils.deleteTree(tempDir); } }
private String createWorldFilePath(String imageFilePath) { String imageFileExt = FileUtils.getExtension(imageFilePath); // Rule for world file extension: <name>.<a><b><c> --> <name>.<a><c>w // see http://support.esri.com/index.cfm?fa=knowledgebase.techarticles.articleShow&d=17489 String worldFilePath; if (imageFileExt != null && imageFileExt.length() == 4) { // three chars + leading dot String worldFileExt = imageFileExt.substring(0, 2) + imageFileExt.charAt(imageFileExt.length() - 1) + "w"; worldFilePath = FileUtils.exchangeExtension(imageFilePath, worldFileExt); } else { worldFilePath = imageFilePath + "w"; } return worldFilePath; }
private static boolean isFASTFormat(final String FileName) { String fileExtension = FileUtils.getExtension(FileName); return LandsatConstants.LANDSAT_EXTENSIONS[LandsatConstants.FAST_L5].equalsIgnoreCase(fileExtension); } }
/** * 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*/ } }
@Override public void setTargetFileTemplatePath(String targetFileTemplatePath) { targetFilePath = FileUtils.exchangeExtension(new File(targetFileTemplatePath), "-bins.nc"); }
String fileExtension = FileUtils.getExtension(file); if (fileExtension == null || !StringUtils.contains(beamFileFilter.getExtensions(), fileExtension)) { file = FileUtils.ensureExtension(file, beamFileFilter.getDefaultExtension());
public static String readText(File file) throws IOException { final FileReader reader1 = new FileReader(file); try { return readText(reader1); } finally { reader1.close(); } }
private static boolean isFASTFormat(final String FileName) { String fileExtension = FileUtils.getExtension(FileName); return LandsatConstants.LANDSAT_EXTENSIONS[LandsatConstants.FAST_L5].equalsIgnoreCase(fileExtension); }
return file; return new File(ensureExtension(path, extension));
public boolean accept(final File file) { boolean isDataWithDim = file.getName().endsWith(".data") && FileUtils.exchangeExtension(file, ".dim").exists(); return file.isDirectory() && !isDataWithDim; } }
private static String loadConfigProperties(String configPath) throws IOException { try (InputStreamReader inputStreamReader = new InputStreamReader(BinningConfigTest.class.getResourceAsStream(configPath))) { return FileUtils.readText(inputStreamReader).trim(); } }
@Override public String getProductName() { return FileUtils.getFilenameWithoutExtension(inputFile); }
@Override public void end() throws IOException { if (writeRgb) { writeRgbImage(outputRegion.width, outputRegion.height, bandData, bandMinValues, bandMaxValues, outputFormat, outputFile); } else { for (int i = 0; i < bandCount; i++) { String fileName = String.format("%s_%s%s", FileUtils.getFilenameWithoutExtension(outputFile), bandNames[i], FileUtils.getExtension(outputFile)); File imageFile = new File(outputFile.getParentFile(), fileName); writeGrayScaleImage(outputRegion.width, outputRegion.height, bandData[i], bandMinValues[i], bandMaxValues[i], outputFormat, imageFile); } } }
@Override public void close() { if (extractDir != null) { FileUtils.deleteTree(extractDir); extractDir = null; } }
/** * Gets the extension (which always includes a leading dot) of a file. * * @param file the file whose extension is to be extracted. * @return the extension string which always includes a leading dot. Returns <code>null</code> if the file has * no extension. */ public static String getExtension(File file) { Guardian.assertNotNull("file", file); return getExtension(file.getPath()); }
String innerImgZipPath = FileUtils.ensureExtension(innerHdrZipPath, EnviConstants.IMG_EXTENSION); final Enumeration<? extends ZipEntry> enumeration = productZip.entries();
private boolean isDataDir(File dir) { return hasDataExt(dir) && FileUtils.exchangeExtension(dir, DIMAP_HEADER_FILE_EXTENSION).isFile(); }
private FormatterConfig loadConfig(String configPath) throws IOException, BindingException { final InputStreamReader reader = new InputStreamReader(getClass().getResourceAsStream(configPath)); try { return FormatterConfig.fromXml(FileUtils.readText(reader)); } finally { reader.close(); } } }