org.esa.snap.core.util.io.FileUtils.exchangeExtension()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(9.5k)|赞(0)|评价(0)|浏览(112)

本文整理了Java中org.esa.snap.core.util.io.FileUtils.exchangeExtension()方法的一些代码示例,展示了FileUtils.exchangeExtension()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtils.exchangeExtension()方法的具体详情如下:
包路径:org.esa.snap.core.util.io.FileUtils
类名称:FileUtils
方法名:exchangeExtension

FileUtils.exchangeExtension介绍

暂无

代码示例

代码示例来源:origin: senbox-org/s2tbx

private File getFirstComponentOutputFile(File outputFile) {
  return FileUtils.exchangeExtension(outputFile, "_0.pgx");
}

代码示例来源:origin: senbox-org/snap-desktop

private String createNewProductName(String sourceProductName, int productIndex) {
  String newNameBase = "";
  if (sourceProductName != null && sourceProductName.length() > 0) {
    newNameBase = FileUtils.exchangeExtension(sourceProductName, "");
  }
  String newNamePrefix = "subset";
  String newProductName;
  if (newNameBase.length() > 0) {
    newProductName = newNamePrefix + "_" + productIndex + "_" + newNameBase;
  } else {
    newProductName = newNamePrefix + "_" + productIndex;
  }
  return newProductName;
}

代码示例来源:origin: senbox-org/snap-desktop

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;
}

代码示例来源:origin: senbox-org/snap-desktop

private String createNewProductName(String sourceProductName) {
    String newNameBase = "";
    if (sourceProductName != null && sourceProductName.length() > 0) {
      newNameBase = FileUtils.exchangeExtension(sourceProductName, "");
    }
    String newNamePrefix = "product";
    if (hasPrefix()) {
      newNamePrefix = prefix;
    }
    String newProductName;
    if (newNameBase.length() > 0) {
      newProductName = newNamePrefix + "_" + numNewProducts + "_" + newNameBase;
    } else {
      newProductName = newNamePrefix + "_" + numNewProducts;
    }
    return newProductName;
  }
}

代码示例来源:origin: senbox-org/snap-desktop

public static void moveTo(final ProductEntry entry, final File targetFolder) throws Exception {
  if (isSingleFile(entry)) {
    final File newFile = new File(targetFolder, entry.getFile().getName());
    Files.move(entry.getFile().toPath(), newFile.toPath(), REPLACE_EXISTING, ATOMIC_MOVE);
  } else if (isDimap(entry)) {
    final File newFile = new File(targetFolder, entry.getFile().getName());
    Files.move(entry.getFile().toPath(), newFile.toPath(), REPLACE_EXISTING, ATOMIC_MOVE);
    final String dataFolderName = entry.getFile().getName().replace(
        DimapProductConstants.DIMAP_HEADER_FILE_EXTENSION,
        DimapProductConstants.DIMAP_DATA_DIRECTORY_EXTENSION);
    final File oldDataFolder = new File(entry.getFile().getParentFile(), dataFolderName);
    final File newDataFolder = new File(targetFolder, dataFolderName);
    FileIOUtils.moveFolder(oldDataFolder.toPath(), newDataFolder.toPath());
  } else if (isSMOS(entry)) {
    final File newFile = new File(targetFolder, entry.getFile().getName());
    Files.move(entry.getFile().toPath(), newFile.toPath(), REPLACE_EXISTING, ATOMIC_MOVE);
    final File hdrFile = FileUtils.exchangeExtension(entry.getFile(), ".HDR");
    final File newHdrFile = new File(targetFolder, hdrFile.getName());
    Files.move(hdrFile.toPath(), newHdrFile.toPath(), REPLACE_EXISTING, ATOMIC_MOVE);
  } else if (isFolderProduct(entry)) {
    final File newFile = new File(targetFolder, entry.getFile().getParentFile().getName());
    FileIOUtils.moveFolder(entry.getFile().getParentFile().toPath(), newFile.toPath());
  }
}

代码示例来源:origin: senbox-org/snap-desktop

private static void copyTo(final ProductEntry entry, final File targetFolder) throws Exception {
  if (isSingleFile(entry)) {
    final File newFile = new File(targetFolder, entry.getFile().getName());
    Files.copy(entry.getFile().toPath(), newFile.toPath(), REPLACE_EXISTING);
  } else if (isDimap(entry)) {
    final File newFile = new File(targetFolder, entry.getFile().getName());
    Files.copy(entry.getFile().toPath(), newFile.toPath(), REPLACE_EXISTING);
    final String dataFolderName = entry.getFile().getName().replace(
        DimapProductConstants.DIMAP_HEADER_FILE_EXTENSION,
        DimapProductConstants.DIMAP_DATA_DIRECTORY_EXTENSION);
    final File oldDataFolder = new File(entry.getFile().getParentFile(), dataFolderName);
    final File newDataFolder = new File(targetFolder, dataFolderName);
    FileIOUtils.copyFolder(oldDataFolder.toPath(), newDataFolder.toPath());
  } else if (isSMOS(entry)) {
    final File newFile = new File(targetFolder, entry.getFile().getName());
    Files.copy(entry.getFile().toPath(), newFile.toPath(), REPLACE_EXISTING);
    final File hdrFile = FileUtils.exchangeExtension(entry.getFile(), ".HDR");
    final File newHdrFile = new File(targetFolder, hdrFile.getName());
    Files.copy(hdrFile.toPath(), newHdrFile.toPath(), REPLACE_EXISTING);
  } else if (isFolderProduct(entry)) {
    final File newFile = new File(targetFolder, entry.getFile().getParentFile().getName());
    FileIOUtils.copyFolder(entry.getFile().getParentFile().toPath(), newFile.toPath());
  }
}

代码示例来源:origin: senbox-org/snap-desktop

public static void delete(final ProductEntry entry) throws Exception {
  if (isDimap(entry)) {
    Files.delete(entry.getFile().toPath());
    final String dataFolderName = entry.getFile().getName().replace(
        DimapProductConstants.DIMAP_HEADER_FILE_EXTENSION,
        DimapProductConstants.DIMAP_DATA_DIRECTORY_EXTENSION);
    final File dataFolder = new File(entry.getFile().getParentFile(), dataFolderName);
    FileIOUtils.deleteFolder(dataFolder.toPath());
  } else if (isSMOS(entry)) {
    Files.delete(entry.getFile().toPath());
    final File hdrFile = FileUtils.exchangeExtension(entry.getFile(), ".HDR");
    Files.delete(hdrFile.toPath());
  } else if (isFolderProduct(entry)) {
    FileIOUtils.deleteFolder(entry.getFile().getParentFile().toPath());
  } else if (isSingleFile(entry)) {
    Files.delete(entry.getFile().toPath());
  }
}

代码示例来源:origin: senbox-org/s2tbx

File hdrFile = FileUtils.exchangeExtension(inputFile, ".hdr");
File dblFile = FileUtils.exchangeExtension(inputFile, ".dbl");
if (hdrFile.exists() && dblFile.exists()) {
  canContinue = false;

代码示例来源:origin: senbox-org/s2tbx

try {
  outputFile = new File(cacheDir,
      FileUtils.exchangeExtension(imageFile.getName(),
          String.format("_R%d_TX%d_TY%d.pgx",
              getLevel(), jp2TileX, jp2TileY)));

代码示例来源:origin: senbox-org/snap-desktop

/**
 * Sets the current filename.
 *
 * @param currentFilename The current filename, or {@code null}.
 */
public void setCurrentFilename(String currentFilename) {
  Debug.trace("SnapFileChooser: setCurrentFilename(\"" + currentFilename + "\")");
  String defaultExtension = getDefaultExtension();
  if (getDialogType() != JFileChooser.OPEN_DIALOG) {
    if (currentFilename != null && defaultExtension != null) {
      FileFilter fileFilter = getFileFilter();
      if (fileFilter instanceof SnapFileFilter) {
        SnapFileFilter filter = (SnapFileFilter) fileFilter;
        if (!filter.checkExtension(currentFilename)) {
          currentFilename = FileUtils.exchangeExtension(currentFilename, defaultExtension);
        }
      } else if (fileFilter instanceof FileNameExtensionFilter) {
        FileNameExtensionFilter filter = (FileNameExtensionFilter) fileFilter;
        if (!SnapFileFilter.checkExtensions(currentFilename, filter.getExtensions())) {
          currentFilename = FileUtils.exchangeExtension(currentFilename, defaultExtension);
        }
      }
    }
  }
  if (currentFilename != null && currentFilename.length() > 0) {
    setSelectedFile(new File(getCurrentDirectory(), currentFilename));
  }
}

代码示例来源:origin: senbox-org/snap-desktop

private void ensureSelectedFileHasValidExtension() {
  File selectedFile = getSelectedFile();
  if (selectedFile != null) {
    SnapFileFilter mff = getSnapFileFilter();
    if (mff != null
      && mff.getDefaultExtension() != null
      && !mff.checkExtension(selectedFile)) {
      selectedFile = FileUtils.exchangeExtension(selectedFile, mff.getDefaultExtension());
      Debug.trace("mod. selected file: " + selectedFile.getPath());
      setSelectedFile(selectedFile);
    }
  }
}

代码示例来源:origin: senbox-org/s1tbx

private static void getQCFiles(final String missionPrefix, final String orbitType, int year, int month,
                final double stateVectorTime) throws Exception {
  final File localFolder = getDestFolder(missionPrefix, orbitType, year, month);
  final QCScraper qc = new QCScraper(orbitType);
  final String[] orbitFiles = qc.getFileURLs(missionPrefix, year, month);
  final URL remotePath = new URL(qc.getRemoteURL());
  final SSLUtil ssl = new SSLUtil();
  ssl.disableSSLCertificateCheck();
  for (String file : orbitFiles) {
    if (isWithinRange(file, stateVectorTime)) {
      final File localFile = new File(localFolder, file);
      DownloadableContentImpl.getRemoteHttpFile(remotePath, localFile);
      if (localFile.exists()) {
        final File localZipFile = FileUtils.exchangeExtension(localFile, ".EOF.zip");
        ZipUtils.zipFile(localFile, localZipFile);
        localFile.delete();
      }
    }
  }
  ssl.enableSSLCertificateCheck();
}

代码示例来源:origin: senbox-org/snap-desktop

fileChooser.setSelectedFile(new File(FileUtils.exchangeExtension(fileName, defaultExtension)));

代码示例来源:origin: senbox-org/s1tbx

final String annotation = FileUtils.exchangeExtension(imgXMLName, ".xml");
final MetadataElement origProdRoot = AbstractMetadata.getOriginalProductMetadata(product);
final MetadataElement annotationElem = origProdRoot.getElement("annotation");

代码示例来源:origin: senbox-org/s1tbx

final String imgName = FileUtils.exchangeExtension(metadataFile, ".tiff");
imgBandMetadataMap.put(imgName, bandRootName);

代码示例来源:origin: senbox-org/s1tbx

return;
final String annotation = FileUtils.exchangeExtension(imgXMLName, ".xml");
final MetadataElement origProdRoot = AbstractMetadata.getOriginalProductMetadata(product);
final MetadataElement annotationElem = origProdRoot.getElement("annotation");

相关文章