当前位置: 首页>>代码示例>>Java>>正文


Java Files.getFileExtension方法代码示例

本文整理汇总了Java中com.google.common.io.Files.getFileExtension方法的典型用法代码示例。如果您正苦于以下问题:Java Files.getFileExtension方法的具体用法?Java Files.getFileExtension怎么用?Java Files.getFileExtension使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.io.Files的用法示例。


在下文中一共展示了Files.getFileExtension方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createAndInitializeInfo

import com.google.common.io.Files; //导入方法依赖的package包/类
/**
   * Initializes dictionary information for given application from application bundle file (or xml/sdef dictionary file)
   * and saves generated dictionary file for later use by {@link ApplicationDictionary} PSI class
   *
   * @param applicationIoFile File of the application bundle or dictionary file (.app, .osax, .xml, .sdef extensions
   *                          are supported)
   * @param applicationName   Name of the Mac OS X application
   * @return {@link DictionaryInfo} of the generated, saved and initialized dictionary for the application
   */
  @Nullable
  public synchronized DictionaryInfo createAndInitializeInfo(@NotNull File applicationIoFile,
                                                             @NotNull String applicationName) {
//    if (isNotScriptable(applicationName)) return null;
    String appExtension = Files.getFileExtension(applicationIoFile.getPath());
    if (!ApplicationDictionaryImpl.extensionSupported(appExtension)) return null;
    if (!applicationIoFile.exists()) return null;
    if (getDictionaryInfo(applicationName) != null) {
      LOG.warn("Dictionary for application " + applicationName + " was already initialized. Generating new dictionary file any way.");
    }
    final DictionaryInfo createdDictionaryInfo = createDictionaryInfoForApplication(applicationName, applicationIoFile);
    if (createdDictionaryInfo != null) {
      if (initializeDictionaryFromInfo(createdDictionaryInfo))
        return createdDictionaryInfo;
    }
    return null;
  }
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:27,代码来源:AppleScriptSystemDictionaryRegistryService.java

示例2: handleAndroidFile

import com.google.common.io.Files; //导入方法依赖的package包/类
private void handleAndroidFile(CredentialDetail detail, MultipartFile file) throws IOException {
    if (!(detail instanceof AndroidCredentialDetail)) {
        return;
    }

    if (file == null || file.isEmpty()) {
        return;
    }

    AndroidCredentialDetail androidDetail = (AndroidCredentialDetail) detail;
    String extension = Files.getFileExtension(file.getOriginalFilename());

    if (!ANDROID_EXTENSIONS.contains(extension)) {
        throw new IllegalParameterException("Illegal android cert file");
    }

    String destFileName = getFileName(file.getOriginalFilename());
    Path destPath = credentailFilePath(destFileName);

    file.transferTo(destPath.toFile());
    androidDetail.setFile(new FileResource(file.getOriginalFilename(), destPath.toString()));
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:23,代码来源:CredentialController.java

示例3: getUniqueContentName

import com.google.common.io.Files; //导入方法依赖的package包/类
/**
 * Returns a unique name for a file with a given content hash.
 *
 * <p>Directory paths are removed. Example:
 * <pre>
 * dir="a/b/c/d", contentHash="f000" => d-f000.jar
 * file="a/b/c/d.txt", contentHash="f000" => d-f000.txt
 * file="a/b/c/d", contentHash="f000" => d-f000
 * </pre>
 */
private static String getUniqueContentName(File classpathElement, String contentHash) {
  String fileName = Files.getNameWithoutExtension(classpathElement.getAbsolutePath());
  String fileExtension = Files.getFileExtension(classpathElement.getAbsolutePath());
  if (classpathElement.isDirectory()) {
    return fileName + "-" + contentHash + ".jar";
  } else if (fileExtension.isEmpty()) {
    return fileName + "-" + contentHash;
  }
  return fileName + "-" + contentHash + "." + fileExtension;
}
 
开发者ID:spotify,项目名称:hype,代码行数:21,代码来源:StagingUtil.java

示例4: FileCollectionBackedArchiveTextResource

import com.google.common.io.Files; //导入方法依赖的package包/类
public FileCollectionBackedArchiveTextResource(final FileOperations fileOperations,
                                               final TemporaryFileProvider tempFileProvider,
                                               final FileCollection fileCollection,
                                               final String path, Charset charset) {
    super(tempFileProvider, new LazilyInitializedFileCollection() {
        @Override
        public String getDisplayName() {
            return String.format("entry '%s' in archive %s", path, fileCollection);
        }

        @Override
        public FileCollection createDelegate() {
            File archiveFile = fileCollection.getSingleFile();
            String fileExtension = Files.getFileExtension(archiveFile.getName());
            FileTree archiveContents = fileExtension.equals("jar") || fileExtension.equals("zip")
                ? fileOperations.zipTree(archiveFile) : fileOperations.tarTree(archiveFile);
            PatternSet patternSet = new PatternSet();
            patternSet.include(path);
            return archiveContents.matching(patternSet);
        }

        @Override
        public void visitDependencies(TaskDependencyResolveContext context) {
            context.add(fileCollection);
        }
    }, charset);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:28,代码来源:FileCollectionBackedArchiveTextResource.java

示例5: ResourcePackManager

import com.google.common.io.Files; //导入方法依赖的package包/类
public ResourcePackManager(File path) {
    if (!path.exists()) {
        path.mkdirs();
    } else if (!path.isDirectory()) {
        throw new IllegalArgumentException(Server.getInstance().getLanguage()
                .translateString("nukkit.resources.invalid-path", path.getName()));
    }

    List<ResourcePack> loadedResourcePacks = new ArrayList<>();
    for (File pack : path.listFiles()) {
        try {
            ResourcePack resourcePack = null;

            if (!pack.isDirectory()) { //directory resource packs temporarily unsupported
                switch (Files.getFileExtension(pack.getName())) {
                    case "zip":
                    case "mcpack":
                        resourcePack = new ZippedResourcePack(pack);
                        break;
                    default:
                        Server.getInstance().getLogger().warning(Server.getInstance().getLanguage()
                                .translateString("nukkit.resources.unknown-format", pack.getName()));
                        break;
                }
            }

            if (resourcePack != null) {
                loadedResourcePacks.add(resourcePack);
                this.resourcePacksById.put(resourcePack.getPackId(), resourcePack);
            }
        } catch (IllegalArgumentException e) {
            Server.getInstance().getLogger().warning(Server.getInstance().getLanguage()
                    .translateString("nukkit.resources.fail", pack.getName(), e.getMessage()));
        }
    }

    this.resourcePacks = loadedResourcePacks.toArray(new ResourcePack[loadedResourcePacks.size()]);
    Server.getInstance().getLogger().info(Server.getInstance().getLanguage()
            .translateString("nukkit.resources.success", String.valueOf(this.resourcePacks.length)));
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:41,代码来源:ResourcePackManager.java

示例6: handle

import com.google.common.io.Files; //导入方法依赖的package包/类
public void handle(int level, String path, File file) {
    String extension = Files.getFileExtension(file.getName());

    if (extension.equals("java")){
        handleJava(level, path, file);
    }else if(extension.equals("xml") && isLayoutResourceDir(path)){
        handleLayoutXML(level, path, file);
    }
}
 
开发者ID:pRivAte12,项目名称:android-component-explorer,代码行数:10,代码来源:FileHandler.java

示例7: loadPortScannerResult

import com.google.common.io.Files; //导入方法依赖的package包/类
@Override
public PortScannerResult loadPortScannerResult(@NonNull final String _filename,
                                               @NonNull final PortScannerResult _defaultPortScannerResult) {
    final File file = new File(_filename);

    try {
        @Cleanup final FileInputStream fis = new FileInputStream(file);

        log.info("Loading file: " + _filename);

        final String extension = Files.getFileExtension(file.getPath());
        final IoPlugin ioPluginForExtension = pluginConfiguration.getIoPluginByExtension(extension);

        if (ioPluginForExtension != null) {
            // extra mapping meta-data required by YAML plugin, ignored by JSON plugin
            // (Jackson is much smarter with regard to inferring types it seems)
            final MapProperty openHostsMapProperty = new MapProperty(NetworkResult.class, "openHosts", String.class, OpenHost.class);
            final MapProperty openPortsMapProperty = new MapProperty(OpenHost.class, "openPorts", Integer.class, Port.class);
            final PortScannerResult portScannerResult = ioPluginForExtension.load(fis, PortScannerResult.class, Collections.emptyList(), Arrays.asList(openHostsMapProperty, openPortsMapProperty));

            if (portScannerResult != null) {
                log.info("Port scan result loaded.");

                return portScannerResult;
            } else {
                log.warn("Unable to deserialize scan result.");
            }
        } else {
            log.warn("Unable to find registered I/O plugin for extension: " + extension);
        }
    } catch (IOException _e) {
        log.warn("Failed to load port scan result", _e);
    }

    return _defaultPortScannerResult;
}
 
开发者ID:jonfryd,项目名称:tifoon,代码行数:37,代码来源:PortScannerFileIOServiceImpl.java

示例8: ResourcePackManager

import com.google.common.io.Files; //导入方法依赖的package包/类
public ResourcePackManager(File path) {
    if (!path.exists()) {
        path.mkdirs();
    } else if (!path.isDirectory()) {
        throw new IllegalArgumentException(Server.getInstance().getLanguage()
                .translateString("nukkit.resources.invalid-path", path.getName()));
    }

    List<ResourcePack> loadedResourcePacks = new ArrayList<>();
    for (File pack : path.listFiles()) {
        try {
            ResourcePack resourcePack = null;

            if (!pack.isDirectory()) { //directory resource packs temporarily unsupported
                switch (Files.getFileExtension(pack.getName())) {
                    case "zip":
                        resourcePack = new ZippedResourcePack(pack);
                        break;
                    default:
                        Server.getInstance().getLogger().warning(Server.getInstance().getLanguage()
                                .translateString("nukkit.resources.unknown-format", pack.getName()));
                        break;
                }
            }

            if (resourcePack != null) {
                loadedResourcePacks.add(resourcePack);
                this.resourcePacksById.put(resourcePack.getPackId(), resourcePack);
            }
        } catch (IllegalArgumentException e) {
            Server.getInstance().getLogger().warning(Server.getInstance().getLanguage()
                    .translateString("nukkit.resources.fail", pack.getName(), e.getMessage()));
        }
    }

    this.resourcePacks = loadedResourcePacks.toArray(new ResourcePack[loadedResourcePacks.size()]);
    Server.getInstance().getLogger().info(Server.getInstance().getLanguage()
            .translateString("nukkit.resources.success", String.valueOf(this.resourcePacks.length)));
}
 
开发者ID:FrontierDevs,项目名称:Jenisys3,代码行数:40,代码来源:ResourcePackManager.java

示例9: getFilter

import com.google.common.io.Files; //导入方法依赖的package包/类
private static FilenameFilter getFilter(final Set<String> fileExtensions) {
    checkArgument(!fileExtensions.isEmpty(), "No file extension provided", fileExtensions);

    return (dir, name) -> {
        String ext = Files.getFileExtension(name);
        return fileExtensions.contains(ext);
    };
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:9,代码来源:XmlDirectoryPersister.java

示例10: forFile

import com.google.common.io.Files; //导入方法依赖的package包/类
public static AttributeContainer forFile(File file) {
    String extension = Files.getFileExtension(file.getName());
    return createAttributes(extension, extension, "");
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:5,代码来源:DefaultArtifactAttributes.java

示例11: ResourcePackManager

import com.google.common.io.Files; //导入方法依赖的package包/类
public ResourcePackManager(File path) {
    if (!path.exists()) {
        path.mkdirs();
    } else if (!path.isDirectory()) {
        throw new IllegalArgumentException(Server.getInstance().getLanguage()
                .translateString("nukkit.resources.invalid-path", path.getName()));
    }

    List<ResourcePack> loadedResourcePacks = new ArrayList<>();
    for (File pack : path.listFiles()) {
        try {
            ResourcePack resourcePack = null;

            if (!pack.isDirectory()) { //directory resource packs temporarily unsupported
                switch (Files.getFileExtension(pack.getName())) {
                    case "zip":
                    case "mcpack":
                        resourcePack = new ZippedResourcePack(pack);
                        break;
                    default:
                        Server.getInstance().getLogger().warning(Server.getInstance().getLanguage()
                                .translateString("nukkit.resources.unknown-format", pack.getName()));
                        break;
                }
            }

            if (resourcePack != null) {
                loadedResourcePacks.add(resourcePack);
                this.resourcePacksById.put(resourcePack.getPackId(), resourcePack);
            }
        } catch (IllegalArgumentException e) {
            Server.getInstance().getLogger().warning(Server.getInstance().getLanguage()
                    .translateString("nukkit.resources.fail", pack.getName(), e.getMessage()));
            e.printStackTrace();
        }
    }

    this.resourcePacks = loadedResourcePacks.toArray(new ResourcePack[loadedResourcePacks.size()]);
    Server.getInstance().getLogger().info(Server.getInstance().getLanguage()
            .translateString("nukkit.resources.success", String.valueOf(this.resourcePacks.length)));
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:42,代码来源:ResourcePackManager.java

示例12: getFileExtension

import com.google.common.io.Files; //导入方法依赖的package包/类
/**
 * 获取文件名的扩展名部分(不包含.)
 */
public static String getFileExtension(File file) {
	return Files.getFileExtension(file.getName());
}
 
开发者ID:zhangjunfang,项目名称:util,代码行数:7,代码来源:FileUtil.java

示例13: getFileExtension

import com.google.common.io.Files; //导入方法依赖的package包/类
/**
 * Get the extension of the specified file.
 *
 * @param file The file
 * @return The extension of the file
 */
public static String getFileExtension(String file) {
    return Files.getFileExtension(file);
}
 
开发者ID:DianoxDragon,项目名称:UltimateSpawn,代码行数:10,代码来源:FileUtils.java


注:本文中的com.google.common.io.Files.getFileExtension方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。