org.esa.snap.core.util.io.FileUtils类的使用及代码示例

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

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

FileUtils介绍

暂无

代码示例

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

@Override
  public boolean accept(File pathname) {
    return FileUtils.getFilenameWithoutExtension(pathname).equals(classifierName);
  }
});

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

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

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

private static String createName(final File file, final int n) {
  return FileUtils.getFilenameWithoutExtension(file) + '_' + n + FileUtils.getExtension(file);
}

代码示例来源: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/s2tbx

private String findKeyFile(String key) {
    if (key == null || key.isEmpty())
      return null;
    String ret = files.get(key);
    if (ret == null) {
      String namePart = FileUtils.getFilenameWithoutExtension(FileUtils.getFileNameFromPath(key));
      String extPart = FileUtils.getExtension(key);
      ret = firstOrDefault(files.keySet(),
                 k -> {
                   String name = FileUtils.getFilenameWithoutExtension(FileUtils.getFileNameFromPath(k));
                   name = name.substring(name.lastIndexOf("/") + 1);
                   return (extPart != null && extPart.equalsIgnoreCase(FileUtils.getExtension(k))) && namePart.equals(name);
                 });
      //If no identical name found, look for a name that could be a truncated name of key (needed for some Deimos products)
      if(ret == null) {
        ret = firstOrDefault(files.keySet(),
                   k -> {
                     String name = FileUtils.getFilenameWithoutExtension(FileUtils.getFileNameFromPath(k));
                     name = name.substring(name.lastIndexOf("/") + 1);
                     return (extPart != null && extPart.equalsIgnoreCase(FileUtils.getExtension(k))) && namePart.startsWith(name);
                   });
      }
    }
    return ret;
  }
}

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

public static boolean isTar(String filename) {
  return ".tar".equals(FileUtils.getExtension(filename));
}

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

@Override
public void close() {
  if (extractDir != null) {
    FileUtils.deleteTree(extractDir);
    extractDir = null;
  }
}

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

@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"));
}

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

setIODir(file.getAbsoluteFile().getParentFile());
SnapFileFilter snapFileFilter = fileChooser.getSnapFileFilter();
String fileExtension = FileUtils.getExtension(file);
if (fileExtension == null || !StringUtils.contains(snapFileFilter.getExtensions(), fileExtension)) {
  file = FileUtils.ensureExtension(file, snapFileFilter.getDefaultExtension());

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

private String formatFile(File file) {
  return FileUtils.getDisplayText(file, 54);
}

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

public static boolean isValidExtension (File file) {
  boolean validExtension = false;
  final String extension = FileUtils.getExtension(file);
  if (extension == null) {
    validExtension = true;
  } else {
    for (String allowedExtension : allowedExtensions) {
      if (extension.startsWith(allowedExtension)) {
        validExtension = true;
        break;
      }
    }
  }
  return validExtension;
}

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

@Override
public void dispose() {
  super.dispose();
  this.tiles.values().forEach(FileLandCoverTile::dispose);
  this.tiles.clear();
  this.unpackedDirs.forEach(f -> {
    try {
      FileUtils.deleteTree(f);
    } catch (Exception ex) {
      SystemUtils.LOG.warning(ex.getMessage());
    }
  });
  this.unpackedDirs.clear();
}

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

@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]);
      DomElement domElement = parameterSupport.toDomElement();
      escapeXmlElements(domElement);
      String xmlString = domElement.toXml();
      writeToFile(xmlString, selectedFile);
    } catch (Exception e) {
      Debug.trace(e);
      Dialogs.showError(TITLE, "Could not load parameters.\n" + e.getMessage());
    }
  }
}

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

String formatFile(File file) {
  return FileUtils.getDisplayText(file, 54);
}

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

private File getImageFile(final File parFile) {
  return new File(parFile.getParentFile(), FileUtils.getFilenameWithoutExtension(parFile));
}

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

private boolean isCoregistered(final File file) {
  String name = file.getName().toLowerCase();
  name = FileUtils.getFilenameWithoutExtension(name);
  String ext = FileUtils.getExtension(name);
  return ext != null && ext.endsWith("rslc");
}

代码示例来源: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/s2tbx

public static boolean isTgz(String filename) {
  final String extension = FileUtils.getExtension(filename);
  return (".tgz".equals(extension) || ".gz".equals(extension));
}

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

private void deleteTemporaryFolder() {
  boolean deleted = FileUtils.deleteTree(this.temporaryFolder.toFile());
  if (logger.isLoggable(Level.FINE)) {
    logger.log(Level.FINE, ""); // add an empty line
    if (deleted) {
      logger.log(Level.FINE, "Successfully deleted the temporary folder path '" + getTemporaryFolderPath()+"'");
    } else {
      logger.log(Level.FINE, "Failed to delete the temporary folder path '" + getTemporaryFolderPath()+"'");
    }
  }
}

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

if (Boolean.TRUE.equals(Dialogs.requestOverwriteDecision(ACTION_NAME, file))) {
  setDirectory(file.getAbsoluteFile().getParentFile());
  file = FileUtils.ensureExtension(file, ".xml");
  writeXml(file, document);

相关文章