本文整理了Java中org.scijava.util.FileUtils.getExtension()
方法的一些代码示例,展示了FileUtils.getExtension()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtils.getExtension()
方法的具体详情如下:
包路径:org.scijava.util.FileUtils
类名称:FileUtils
方法名:getExtension
[英]Extracts the file extension from a file.
[中]从文件中提取文件扩展名。
代码示例来源:origin: sc.fiji/fiji-compat
/**
* Returns the file extension of a given file
*
* @param path the path to the file
* @return the file extension
* @deprecated see {@link FileUtils#getExtension(String)}
*/
public static String getFileExtension(String path) {
return FileUtils.getExtension(path);
}
代码示例来源:origin: org.scijava/scijava-common
/**
* Extracts the file extension from a file path.
*
* @param path the path to the file (relative or absolute)
* @return the file extension (excluding the dot), or the empty string when
* the file name does not contain dots
*/
public static String getExtension(final String path) {
return getExtension(new File(path));
}
代码示例来源:origin: scijava/scijava-common
/**
* Extracts the file extension from a file path.
*
* @param path the path to the file (relative or absolute)
* @return the file extension (excluding the dot), or the empty string when
* the file name does not contain dots
*/
public static String getExtension(final String path) {
return getExtension(new File(path));
}
代码示例来源:origin: scijava/scijava-common
public boolean canHandleFile(final File file) {
final String extension = FileUtils.getExtension(file);
if ("".equals(extension)) return false;
return byExtension.containsKey(extension);
}
代码示例来源:origin: scijava/scijava-common
public boolean canHandleFile(final String fileName) {
final String extension = FileUtils.getExtension(fileName);
if ("".equals(extension)) return false;
return byExtension.containsKey(extension);
}
代码示例来源:origin: org.scijava/scijava-common
public boolean canHandleFile(final String fileName) {
final String extension = FileUtils.getExtension(fileName);
if ("".equals(extension)) return false;
return byExtension.containsKey(extension);
}
代码示例来源:origin: org.scijava/scijava-common
public boolean canHandleFile(final File file) {
final String extension = FileUtils.getExtension(file);
if ("".equals(extension)) return false;
return byExtension.containsKey(extension);
}
代码示例来源:origin: org.scijava/scijava-common
@Override
default boolean supports(final File file) {
for (final String ext : getExtensions()) {
if (FileUtils.getExtension(file).equalsIgnoreCase(ext)) return true;
}
return false;
}
代码示例来源:origin: scijava/scijava-common
@Override
default boolean supports(final File file) {
for (final String ext : getExtensions()) {
if (FileUtils.getExtension(file).equalsIgnoreCase(ext)) return true;
}
return false;
}
代码示例来源:origin: net.imagej/imagej-updater
/**
* Cache a file locally.
*
* @param url
* the URL of the file to cache
* @param evenLocal
* force "caching" even local files, e.g. to transform the files
* without destroying the original contents
* @return the cached file, or the original file if nothing was cached
* @throws IOException
*/
protected File cacheFile(final URL url, boolean evenLocal) throws IOException {
if (!evenLocal && isLocal(url))
return new File(url.getPath());
String extension = FileUtils.getExtension(url.getFile());
if (extension.startsWith("jar-")) extension = "jar";
final File result = File.createTempFile("diff-", "".equals(extension) ? "" : "." + extension);
result.deleteOnExit();
copy(util.openStream(url), new FileOutputStream(result), true, true);
return result;
}
代码示例来源:origin: org.scijava/scijava-common
/** Gets the scripting language of the script. */
public ScriptLanguage getLanguage() {
if (scriptLanguage == null) {
// infer the language from the script path's extension
final String scriptPath = getPath();
if (scriptPath != null) {
// use language associated with the script path extension
final String extension = FileUtils.getExtension(scriptPath);
scriptLanguage = scriptService.getLanguageByExtension(extension);
}
else {
// use the highest priority language
final List<ScriptLanguage> langs = scriptService.getLanguages();
if (langs != null && !langs.isEmpty()) scriptLanguage = langs.get(0);
}
}
return scriptLanguage;
}
代码示例来源:origin: scijava/scijava-common
/** Gets the scripting language of the script. */
public ScriptLanguage getLanguage() {
if (scriptLanguage == null) {
// infer the language from the script path's extension
final String scriptPath = getPath();
if (scriptPath != null) {
// use language associated with the script path extension
final String extension = FileUtils.getExtension(scriptPath);
scriptLanguage = scriptService.getLanguageByExtension(extension);
}
else {
// use the highest priority language
final List<ScriptLanguage> langs = scriptService.getLanguages();
if (langs != null && !langs.isEmpty()) scriptLanguage = langs.get(0);
}
}
return scriptLanguage;
}
代码示例来源:origin: scijava/scijava-common
@Test
public void testGetExtension() {
assertEquals("ext", FileUtils.getExtension("/path/to/file.ext"));
assertEquals("", FileUtils.getExtension("/path/to/file"));
assertEquals("a", FileUtils.getExtension("/etc/init.d/xyz/file.a"));
assertEquals("", FileUtils.getExtension("/etc/init.d/xyz/file"));
}
内容来源于网络,如有侵权,请联系作者删除!