• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Files类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中io.fabric8.utils.Files的典型用法代码示例。如果您正苦于以下问题:Java Files类的具体用法?Java Files怎么用?Java Files使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: scanProject

import io.fabric8.utils.Files; //导入依赖的package包/类
protected void scanProject(File file, List<FileProcessor> processors, ProjectOverviewDTO overview, int level,
                           int maxLevels) {
    if (file.isFile()) {
        String name = file.getName();
        String extension = Files.getExtension(name);
        for (FileProcessor processor : new ArrayList<>(processors)) {
            if (processor.processes(overview, file, name, extension, level)) {
                processors.remove(processor);
            }
        }
    } else if (file.isDirectory()) {
        int newLevel = level + 1;
        if (newLevel <= maxLevels && !processors.isEmpty()) {
            File[] files = file.listFiles();
            if (files != null) {
                for (File child : files) {
                    scanProject(child, processors, overview, newLevel, maxLevels);
                }
            }
        }
    }
}
 
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:23,代码来源:AbstractProjectOverviewCommand.java


示例2: findPom

import io.fabric8.utils.Files; //导入依赖的package包/类
public static PomFileXml findPom(UIContext context, String project, File pomFile) {
    if (pomFile == null) {
        DirectoryResource initialDir = (DirectoryResource) context.getInitialSelection().get();
        if (initialDir != null) {
            Resource<?> child = initialDir.getChild(project + "/pom.xml");
            if (child.exists()) {
                pomFile = ResourceUtil.getContextFile(child);
            }
        }
    }
    if (Files.isFile(pomFile)) {
        Document doc = null;
        try {
            doc = CheStackDetector.parseXmlFile(pomFile);
        } catch (Exception e) {
            LOG.debug("Failed to parse " + pomFile + " with: " + e, e);
        }
        return new PomFileXml(pomFile, doc);
    }
    return null;
}
 
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:22,代码来源:MavenHelpers.java


示例3: addMatchFiles

import io.fabric8.utils.Files; //导入依赖的package包/类
private void addMatchFiles(List<File> answer, File rootDir, File file) throws IOException {
    if (file.isDirectory()) {
        File[] children = file.listFiles();
        if (children != null) {
            for (File child : children) {
                addMatchFiles(answer, rootDir, child);
            }
        }
    } else {
        String path = Files.getRelativePath(rootDir, file);
        path = Strings.trimAllPrefix(path, "/");
        if (matchesPatterns(path, includes) && !matchesPatterns(path, excludes)) {
            answer.add(file);
        }
    }
}
 
开发者ID:fabric8-updatebot,项目名称:updatebot,代码行数:17,代码来源:FileMatcher.java


示例4: fileExistsInDir

import io.fabric8.utils.Files; //导入依赖的package包/类
protected boolean fileExistsInDir(File dir, String fileName) {
    if (dir.isFile()) {
        return dir.getName().equals(fileName);
    } else if (dir.isDirectory()) {
        if (isFile(new File(dir, fileName))) {
            return true;
        }
        File[] files = dir.listFiles();
        if (files != null) {
            for (File file : files) {
                if (Files.isDirectory(file)) {
                    if (fileExistsInDir(file, fileName)) {
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
 
开发者ID:fabric8-updatebot,项目名称:updatebot,代码行数:21,代码来源:HelmUpdater.java


示例5: removeSnapshotFabric8Artifacts

import io.fabric8.utils.Files; //导入依赖的package包/类
protected void removeSnapshotFabric8Artifacts() {
    File fabric8Folder = new File(localMavenRepo, "io/fabric8");
    if (Files.isDirectory(fabric8Folder)) {
        File[] artifactFolders = fabric8Folder.listFiles();
        if (artifactFolders != null) {
            for (File artifactFolder : artifactFolders) {
                File[] versionFolders = artifactFolder.listFiles();
                if (versionFolders != null) {
                    for (File versionFolder : versionFolders) {
                        if (versionFolder.getName().toUpperCase().endsWith("-SNAPSHOT")) {
                            LOG.info("Removing snapshot version from local maven repo: " + versionFolder);
                            Files.recursiveDelete(versionFolder);
                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:20,代码来源:SpringBootFabric8SetupTest.java


示例6: assertGitCloneRepo

import io.fabric8.utils.Files; //导入依赖的package包/类
/**
 * Asserts that we can git clone the given repository
 */
public static Git assertGitCloneRepo(String cloneUrl, File outputFolder) throws GitAPIException, IOException {
    LOG.info("Cloning git repo: " + cloneUrl + " to folder: " + outputFolder);

    Files.recursiveDelete(outputFolder);
    outputFolder.mkdirs();

    CloneCommand command = Git.cloneRepository();
    command = command.setCloneAllBranches(false).setURI(cloneUrl).setDirectory(outputFolder).setRemote("origin");

    Git git;
    try {
        git = command.call();
    } catch (Exception e) {
        LOG.error("Failed to git clone remote repo " + cloneUrl + " due: " + e.getMessage(), e);
        throw e;
    }
    return git;
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:22,代码来源:ForgeClientAsserts.java


示例7: doRemove

import io.fabric8.utils.Files; //导入依赖的package包/类
protected CommitInfo doRemove(Git git, List<String> paths) throws Exception {
    if (paths != null && paths.size() > 0) {
        int count = 0;
        for (String path : paths) {
            File file = getRelativeFile(path);
            if (file.exists()) {
                count++;
                Files.recursiveDelete(file);
                String filePattern = getFilePattern(path);
                git.rm().addFilepattern(filePattern).call();
            }
        }
        if (count > 0) {
            CommitCommand commit = git.commit().setAll(true).setAuthor(personIdent).setMessage(message);
            return createCommitInfo(commitThenPush(git, commit));
        }
    }
    return null;
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:20,代码来源:RepositoryResource.java


示例8: createFileDTO

import io.fabric8.utils.Files; //导入依赖的package包/类
protected FileDTO createFileDTO(File file, boolean includeContent) {
    File parentFile = file.getParentFile();
    String relativePath = null;
    try {
        relativePath = trimLeadingSlash(Files.getRelativePath(basedir, parentFile));
    } catch (IOException e) {
        LOG.warn("Failed to find relative path of " + parentFile.getPath() + ". " + e, e);
    }
    FileDTO answer = FileDTO.createFileDTO(file, relativePath, includeContent, "", false);
    String path = answer.getPath();
    if (path.equals(".git")) {
        // lets ignore the git folder!
        return null;
    }
    // TODO use the path to generate the links...
    // TODO generate the SHA
    return answer;
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:19,代码来源:RepositoryResource.java


示例9: main

import io.fabric8.utils.Files; //导入依赖的package包/类
public static void main(String[] args) {
    if (args.length < 2) {
        System.out.println("Arguments: gitUrl gitTag");
        return;
    }

    String cloneUrl = args[0];
    String tag = args[1];

    File projectFolder = new File("target/myproject");
    if (projectFolder.exists()) {
        Files.recursiveDelete(projectFolder);
    }
    String remote = "origin";

    ProjectFileSystem.cloneRepo(projectFolder, cloneUrl, null, null, null, remote, tag);
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:18,代码来源:GitCloneWithTagExample.java


示例10: main

import io.fabric8.utils.Files; //导入依赖的package包/类
public static void main(String[] args) {
    if (args.length < 3) {
        System.out.println("Arguments: gitUrl privateKeyFile publicKeyFile");
        return;
    }
    String cloneUrl = args[0];
    String privateKeyPath = args[1];
    String publicKeyPath = args[2];


    File projectFolder = new File("target/myproject");
    if (projectFolder.exists()) {
        Files.recursiveDelete(projectFolder);
    }
    File sshPrivateKey = new File(privateKeyPath);
    File sshPublicKey = new File(publicKeyPath);
    String remote = "origin";
    assertThat(sshPrivateKey).exists();
    assertThat(sshPublicKey).exists();

    ProjectFileSystem.cloneRepo(projectFolder, cloneUrl, null, sshPrivateKey, sshPublicKey, remote);
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:23,代码来源:SshGitCloneExample.java


示例11: scanProject

import io.fabric8.utils.Files; //导入依赖的package包/类
protected void scanProject(File file, List<GetOverviewCommand.FileProcessor> processors, ProjectOverviewDTO overview, int level, int maxLevels) {
    if (file.isFile()) {
        String name = file.getName();
        String extension = Files.getExtension(name);
        for (GetOverviewCommand.FileProcessor processor : new ArrayList<>(processors)) {
            if (processor.processes(overview, file, name, extension, level)) {
                processors.remove(processor);
            }
        }
    } else if (file.isDirectory()) {
        int newLevel = level + 1;
        if (newLevel <= maxLevels && !processors.isEmpty()) {
            File[] files = file.listFiles();
            if (files != null) {
                for (File child : files) {
                    scanProject(child, processors, overview, newLevel, maxLevels);
                }
            }
        }
    }
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:22,代码来源:AbstractDevOpsCommand.java


示例12: swizzleFile

import io.fabric8.utils.Files; //导入依赖的package包/类
public void swizzleFile(File file) throws IOException {
    System.out.println("  swizzling: " + file);
    List<String> lines = Files.readLines(file);
    Pattern pattern = Pattern.compile(replaceRegex);

    try (FileWriter writer = new FileWriter(file)) {
        for (String line : lines) {
            String text = line;
            String answer = "";
            Matcher matcher = pattern.matcher(text);
            while (matcher.find()) {
                int start = matcher.start(1);
                int end = matcher.end(1);
                String currentPort = text.substring(start, end);
                String replacePort = portMapper.getReplacementPort(appName, currentPort);
                answer += text.substring(0, start) + replacePort;
                text = text.substring(end);
                matcher = pattern.matcher(text);
            }
            answer += text;
            writer.append(answer);
            writer.append("\n");
        }
    }
}
 
开发者ID:fabric8io,项目名称:portswizzler,代码行数:26,代码来源:PortSwizzler.java


示例13: exportKibanaObjectsForType

import io.fabric8.utils.Files; //导入依赖的package包/类
public static void exportKibanaObjectsForType(ElasticsearchClient es, String type, File dir) throws IOException {
    System.out.println("Finding kibana objects of type: " + type);
    dir.mkdirs();
    SearchDTO search = new SearchDTO();
    search.matchAll();
    ObjectNode results = es.search(index, type, search);

    JsonNode hitArray = results.path("hits").path("hits");
    if (hitArray.isArray()) {
        for (int i = 0, size = hitArray.size(); i < size; i++) {
            JsonNode item = hitArray.get(i);
            if (item != null) {
                JsonNode idNode = item.get("_id");
                String id = idNode.asText();
                JsonNode source = item.get("_source");
                if (Strings.isNotBlank(id) && source.isObject()) {
                    File file = new File(dir, id + ".json");
                    String json = JsonHelper.toJson(source);
                    Files.writeToFile(file, json.getBytes());
                }
            }
        }
    }
}
 
开发者ID:fabric8io,项目名称:fabric8-devops,代码行数:25,代码来源:ExportKibanaObjects.java


示例14: cloneOrPullRepo

import io.fabric8.utils.Files; //导入依赖的package包/类
public File cloneOrPullRepo(UserDetails userDetails, File projectFolder, String cloneUrl, File sshPrivateKey,
                            File sshPublicKey) {
    File gitFolder = new File(projectFolder, ".git");
    CredentialsProvider credentialsProvider = userDetails.createCredentialsProvider();
    if (!Files.isDirectory(gitFolder) || !Files.isDirectory(projectFolder)) {
        // lets clone the git repository!
        cloneRepo(projectFolder, cloneUrl, credentialsProvider, sshPrivateKey, sshPublicKey, this.remote,
                  this.jenkinsfileLibraryGitTag);
    } else {
        doPull(gitFolder, credentialsProvider, userDetails.getBranch(), userDetails.createPersonIdent(), userDetails);
    }
    return projectFolder;
}
 
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:14,代码来源:JenkinsPipelineLibrary.java


示例15: cloneRepoIfNotExist

import io.fabric8.utils.Files; //导入依赖的package包/类
public File cloneRepoIfNotExist(UserDetails userDetails, File projectFolder, String cloneUrl) {
    File gitFolder = new File(projectFolder, ".git");
    CredentialsProvider credentialsProvider = userDetails.createCredentialsProvider();
    if (!Files.isDirectory(gitFolder) || !Files.isDirectory(projectFolder)) {
        // lets clone the git repository!
        cloneRepo(projectFolder, cloneUrl, credentialsProvider, userDetails.getSshPrivateKey(),
                  userDetails.getSshPublicKey(), this.remote);

    }
    return projectFolder;
}
 
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:12,代码来源:JenkinsPipelineLibrary.java


示例16: hasFile

import io.fabric8.utils.Files; //导入依赖的package包/类
/**
 * Returns true if the project has one of the given files
 */
private static boolean hasFile(UIContext context, org.jboss.forge.addon.projects.Project project, String... fileNames) {
    for (String fileName : fileNames) {
        File file = CommandHelpers.getProjectContextFile(context, project, fileName);
        if (Files.isFile(file)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:fabric8-launcher,项目名称:launcher-backend,代码行数:13,代码来源:CheStackDetector.java


示例17: validateConfiguration

import io.fabric8.utils.Files; //导入依赖的package包/类
@Override
protected void validateConfiguration(Configuration configuration) throws IOException {
    File dir = configuration.getSourceDir();
    if (this.cloneUrl == null) {
        if (dir != null) {
            if (!Files.isDirectory(dir)) {
                throw new ParameterException("Directory does not exist " + dir);
            }
            String url;
            try {
                url = GitHelpers.extractGitUrl(dir);
            } catch (IOException e) {
                throw new ParameterException("Could not find the git clone URL in " + dir + ". " + e, e);
            }
            if (url != null) {
                setCloneUrl(GitHelper.removeUsernamePassword(url));
            }
        }
    }
    validateCloneUrl();

    if (sourceRepository == null) {
        sourceRepository = findLocalRepository(configuration);
    }
    if (sourceRepository == null) {
        File sourceDir = configuration.getSourceDir();
        if (sourceDir != null) {
            GitRepository repo = new GitRepository(dir.getName());
            // TODO create a GitHubRepository if we can figure that out
            repo.setCloneUrl(getCloneUrl());
            this.sourceRepository = new LocalRepository(repo, dir);
        }
    }

    if (dir != null) {
        configuration.setSourceDir(dir);
    }
}
 
开发者ID:fabric8-updatebot,项目名称:updatebot,代码行数:39,代码来源:PushSourceChanges.java


示例18: fromDirectory

import io.fabric8.utils.Files; //导入依赖的package包/类
/**
 * Returns a local repository from a directory.
 */
public static LocalRepository fromDirectory(Configuration configuration, File dir) throws IOException {
    LocalRepository localRepository = new LocalRepository(new GitRepository(dir.getName()), dir);
    File configFile = new File(dir, DEFAULT_CONFIG_FILE);
    if (Files.isFile(configFile)) {
        RepositoryConfig config = RepositoryConfigs.loadRepositoryConfig(configuration, DEFAULT_CONFIG_FILE, dir);
        if (config != null) {
            GitRepositoryConfig local = config.getLocal();
            if (local != null) {
                localRepository.getRepo().setRepositoryDetails(local);
            }
        }
    }
    return localRepository;
}
 
开发者ID:fabric8-updatebot,项目名称:updatebot,代码行数:18,代码来源:LocalRepository.java


示例19: loadFile

import io.fabric8.utils.Files; //导入依赖的package包/类
protected static String loadFile(File file) {
    String output = null;
    if (Files.isFile(file)) {
        try {
            output = IOHelpers.readFully(file);
        } catch (IOException e) {
            LOG.error("Failed to load " + file + ". " + e, e);
        }
    }
    return output;
}
 
开发者ID:fabric8-updatebot,项目名称:updatebot,代码行数:12,代码来源:ProcessHelper.java


示例20: getRelativePathToCurrentDir

import io.fabric8.utils.Files; //导入依赖的package包/类
public static Object getRelativePathToCurrentDir(File dir) {
    File currentDir = new File(System.getProperty("user.dir", "."));
    try {
        String relativePath = Files.getRelativePath(currentDir, dir);
        if (relativePath.startsWith("/")) {
            return relativePath.substring(1);
        }
        return relativePath;
    } catch (IOException e) {
        return dir;
    }
}
 
开发者ID:fabric8-updatebot,项目名称:updatebot,代码行数:13,代码来源:FileHelper.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java JavaCallInfo类代码示例发布时间:2022-05-22
下一篇:
Java ServerMessageHeader类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap