slash.common.io.Files.getExtension()方法的使用及代码示例

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

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

Files.getExtension介绍

暂无

代码示例

代码示例来源:origin: cpesch/RouteConverter

/**
 * @param file the file to find the extension
 * @return the extension of the file, which are the characters
 * starting with the last dot in the file name in lowercase characters
 */
public static String getExtension(File file) {
  return getExtension(file.getName());
}

代码示例来源:origin: cpesch/RouteConverter

public boolean accept(File dir, String name) {
    return getExtension(name).equals(".brf");
  }
});

代码示例来源:origin: cpesch/RouteConverter

public static String getExtension(List<URL> urls) {
  String extension = "";
  for (URL url : urls) {
    extension = getExtension(url.toExternalForm());
  }
  return extension.toLowerCase();
}

代码示例来源:origin: cpesch/RouteConverter

/**
 * Remove the extension of the given file name, if there is any.
 *
 * @param name the file name to remove the extension
 * @return the file name without an extension
 */
public static String removeExtension(String name) {
  String extension = getExtension(name);
  return name.substring(0, name.length() - extension.length());
}

代码示例来源:origin: cpesch/RouteConverter

public boolean accept(File file) {
    return file.isDirectory() && !file.getName().startsWith(".") ||
        file.isFile() && getExtension(file).equals(".lnk");
  }
}

代码示例来源:origin: cpesch/RouteConverter

public boolean accept(File f) {
  return f.isDirectory() || format.getExtension().equals(getExtension(f.getName()));
}

代码示例来源:origin: cpesch/RouteConverter

if (path.isFile()) {
  if (collectFiles &&
      (extension == null || getExtension(path).equals(extension)))
    list.add(path);

代码示例来源:origin: cpesch/RouteConverter

/**
 * Provides a quick test to see if this could be a valid link !
 * If you try to instantiate a new WindowShortcut and the link is not valid,
 * Exceptions may be thrown and Exceptions are extremely slow to generate,
 * therefore any code needing to loop through several files should first check this.
 *
 * @param file the potential link
 * @return true if may be a link, false otherwise
 * @throws IOException if an IOException is thrown while reading from the file
 */
public static boolean isPotentialValidLink(File file) throws IOException {
  if (!file.isFile() || !getExtension(file).equals(".lnk"))
    return false;
  try (InputStream inputStream = new FileInputStream(file)) {
    return inputStream.available() >= MINIMUM_LENGTH && isMagicPresent(getBytes(inputStream, 32));
  }
}

代码示例来源:origin: cpesch/RouteConverter

public void read(InputStream source, ParserContext<BaseRoute> context) {
  try (ZipInputStream zip = new ZipInputStream(source)) {
    ZipEntry entry;
    while ((entry = zip.getNextEntry()) != null) {
      if(entry.isDirectory())
        continue;
      NotClosingUnderlyingInputStream buffer = new NotClosingUnderlyingInputStream(new BufferedInputStream(zip));
      int size = (int) entry.getSize() + 1;
      buffer.mark(size);
      context.parse(buffer, context.getStartDate(), Files.getExtension(entry.getName()));
      zip.closeEntry();
    }
  } catch (IOException e) {
    log.fine("Error reading invalid zip entry from " + source + ": " + e);
  }
}

代码示例来源:origin: cpesch/RouteConverter

public void openPositionList(List<URL> urls) {
  if (!confirmDiscard())
    return;
  prepareForNewPositionList();
  openPositionList(urls, getNavigationFormatRegistry().getReadFormatsPreferredByExtension(getExtension(urls)));
}

代码示例来源:origin: cpesch/RouteConverter

public void openFile() {
  if (!confirmDiscard())
    return;
  RouteConverter r = RouteConverter.getInstance();
  JFileChooser chooser = createJFileChooser();
  chooser.setDialogTitle(RouteConverter.getBundle().getString("open-file-dialog-title"));
  setReadFormatFileFilters(chooser);
  chooser.setSelectedFile(createSelectedSource());
  chooser.setFileSelectionMode(FILES_ONLY);
  chooser.setMultiSelectionEnabled(true);
  int open = chooser.showOpenDialog(r.getFrame());
  if (open != APPROVE_OPTION)
    return;
  File[] selected = chooser.getSelectedFiles();
  if (selected == null || selected.length == 0)
    return;
  NavigationFormat selectedFormat = getSelectedFormat(chooser.getFileFilter());
  setReadFormatFileFilterPreference(selectedFormat);
  prepareForNewPositionList();
  List<URL> urls = toUrls(selected);
  List<NavigationFormat> formats = selectedFormat != null ?
      getNavigationFormatRegistry().getReadFormatsWithPreferredFormat(selectedFormat) :
      getNavigationFormatRegistry().getReadFormatsPreferredByExtension(getExtension(urls));
  openPositionList(urls, formats);
}

相关文章