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


Java FileUtil类代码示例

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


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

示例1: allModules

import org.aspectj.util.FileUtil; //导入依赖的package包/类
public List<String> allModules() throws IOException {
    List<String> modules = new ArrayList<>();

    File rootModule = new ClassPathResource("/static/apps/admin/modules").getFile();

    for (File f : FileUtil.listFiles(rootModule, (pathname -> pathname.getName().toLowerCase().endsWith(".html")))) {
        String moduleName = f.getPath()
            .replace(".html", "")
            .replace(rootModule.getAbsolutePath(), "")
            .replaceAll("[\\\\/]+", "-")
            .replaceAll("^-", "");

        modules.add(moduleName);
    }

    return modules;
}
 
开发者ID:bndynet,项目名称:web-framework-for-java,代码行数:18,代码来源:AppService.java

示例2: testNotAuthorized

import org.aspectj.util.FileUtil; //导入依赖的package包/类
@Test
public void testNotAuthorized() throws Exception {
  myArtifactsCollections.add(DeployTestUtils.buildArtifactsCollection(myTempFiles, "dest1", "dest2"));
  final BuildProcess process = new FtpBuildProcessAdapter(myContext, "127.0.0.1:" + testPort, myUsername, "wrongpassword", myArtifactsCollections);

  process.start();
  new WaitFor(5000) {
    @Override
    protected boolean condition() {
      return process.isFinished();
    }
  };
  assertThat(process.isFinished()).describedAs("Failed to finish test in time").isTrue();
  assertThat(process.waitFor()).isEqualTo(BuildFinishedStatus.FINISHED_FAILED);
  assertEquals(FileUtil.listFiles(myRemoteDir).length, 0);
}
 
开发者ID:JetBrains,项目名称:teamcity-deployer-plugin,代码行数:17,代码来源:FtpBuildProcessAdapterTest.java

示例3: shouldRemoveFlyweightWhenConfiguredBranchDoesNotExist

import org.aspectj.util.FileUtil; //导入依赖的package包/类
@Test
public void shouldRemoveFlyweightWhenConfiguredBranchDoesNotExist() throws Exception {
    File flyweightDir = new File("pipelines", "flyweight");
    FileUtils.deleteQuietly(flyweightDir);

    material = new GitMaterial(testRepo.projectRepositoryUrl(), "bad-bad-branch");

    try {
        updater.updateMaterial(material);
        fail("material update should have failed as given branch does not exist in repository");
    } catch (Exception e) {
        //ignore
    }

    MaterialInstance materialInstance = materialRepository.findMaterialInstance(material);

    assertThat(materialInstance, is(nullValue()));
    assertThat(FileUtil.listFiles(flyweightDir).length, is(0));//no flyweight dir left behind
}
 
开发者ID:gocd,项目名称:gocd,代码行数:20,代码来源:MaterialDatabaseGitUpdaterTest.java

示例4: getAddressFromFile

import org.aspectj.util.FileUtil; //导入依赖的package包/类
private Map<String, String> getAddressFromFile() {
    Map<String, String> content = new HashMap<String, String>();
    try {
        String contentS = FileUtil.readAsString(new File((String) PropertyFactory.getProperty("registry.address.backup.filename")));
        String[] contentArray = contentS.split("。");
        for (String temp : contentArray) {
            String[] tempArray = temp.split("=");
            content.put(tempArray[0], tempArray[1]);
        }
        logger.info("read registry address from the local file success");
    } catch (Exception e) {
        logger.error("read registry address from the local file failure!" + e.getMessage(), e);
    }
    return content;
}
 
开发者ID:tiglabs,项目名称:jsf-core,代码行数:16,代码来源:RegistryAddressCache.java

示例5: main

import org.aspectj.util.FileUtil; //导入依赖的package包/类
public static void main(String[] args)  throws Exception{

		String url = "http://localhost:8080/juranhome/test/lz4";

		BDHttpParam pm = BDHttpParam.init();
		
		String path = "/home/dcy/tmp/bigjson";
		File file = new File(path);
		byte[] data = FileUtil.readAsByteArray(file);
		byte[] comp = Lz4Compress.compress(data);
		pm.addCommon("lz4", new String(comp,"utf-8"));

		String res = BDHttpUtil.sendPost(url, pm);
		System.out.println(res);
	}
 
开发者ID:bdceo,项目名称:bd-codes,代码行数:16,代码来源:RestTest.java

示例6: getImages

import org.aspectj.util.FileUtil; //导入依赖的package包/类
@Override
public List<FileJson> getImages() {
    ArrayList<FileJson> images = Lists.newArrayList();

    for (String fileName : FileUtil.listFiles(new File(path))) {
        if (isAcceptableFile(fileName)) {
            images.add(new FileJson(fileName, toUri(fileName)));
        }
    }
    return images;
}
 
开发者ID:solita,项目名称:kansalaisaloite,代码行数:12,代码来源:FileImageFinder.java

示例7: getFile

import org.aspectj.util.FileUtil; //导入依赖的package包/类
@Override
@Cacheable("infoTextImages")
public FileInfo getFile(String fileName, String version) throws IOException {

    assertFileName(fileName);

    File file = new File(path + "/" + fileName);
    if (!file.exists()) {
        throw new NotFoundException("image", fileName);
    }
    byte[] bytes = FileUtil.readAsByteArray(file);
    return new FileInfo(Arrays.copyOf(bytes,bytes.length), file.lastModified());
}
 
开发者ID:solita,项目名称:kansalaisaloite,代码行数:14,代码来源:FileImageFinder.java

示例8: writeEmailsToHtml

import org.aspectj.util.FileUtil; //导入依赖的package包/类
private void writeEmailsToHtml() {
    for (EmailHelper sentEmail : sentEmails) {
        File file = new File(EMAIL_TEMP_DIR
                + new LocalDateTime().toString("mmssSSS")
                + "_"
                + sentEmail.subject.replace("/", " - ")
                + "_"
                + sentEmail.to
                + ".html");
        FileUtil.writeAsString(file, sentEmail.html);
    }


}
 
开发者ID:solita,项目名称:kansalaisaloite,代码行数:15,代码来源:EmailSpyConfiguration.java

示例9: getConfigurationContent

import org.aspectj.util.FileUtil; //导入依赖的package包/类
public String getConfigurationContent(String host, String confFileName)
		throws Exception {
	String fileContent = null;
	Map<String, Object> configValues = getConfigValueMap();

	String udpRecvChannel = "udp_recv_channel {\n port = "
			+ configValues.get("port") + " \n } ";
	// 'udp_recv_channel' value for gmond.conf
	configValues.put("udp_recv_channel", "/*" + udpRecvChannel + "*/");

	if (((String) advanceConf
			.get(GangliaConstants.ClusterProperties.GMETAD_HOST))
			.equals(host)) {
		StringBuffer nodeIpPorts = new StringBuffer();
		// Preparing a String of nodeIp:port of gmetad node used in
		// data_source in gmetad.conf.
		nodeIpPorts
				.append(advanceConf
						.get(GangliaConstants.ClusterProperties.GMETAD_HOST))
				.append(Symbols.STR_COLON);
		nodeIpPorts.append(advanceConf
				.get(GangliaConstants.ClusterProperties.GANGLIA_PORT));
		// Putting the nodeIpsPorts string in map
		configValues.put("nodeIpsPorts", nodeIpPorts.toString());
		// On gmond nodes other than Gmetad node commenting
		// udp_recv_channel block
		configValues.put("udp_recv_channel", udpRecvChannel);
	}
	// Reading the content of the template file
	fileContent = FileUtil.readAsString(new File(confFileName));

	// Creating a string substitutor using config values map
	StrSubstitutor sub = new StrSubstitutor(configValues);

	// Replacing the config values key found in the file content with
	// respected values.
	return sub.replace(fileContent);
}
 
开发者ID:Impetus,项目名称:ankush,代码行数:39,代码来源:GangliaDeployer.java

示例10: testGenerate

import org.aspectj.util.FileUtil; //导入依赖的package包/类
@Test
public void testGenerate() {
    // setup
    Map<String, Object> model = new HashMap<String, Object>();
    model.put("name", "adrian");
    FileUtil.writeAsString(tmpFile, "name=${name}");

    // act
    String result = templateHelper.generate(tmpFile.getName(), model);

    // assert
    assertEquals("name=adrian", result);
}
 
开发者ID:barnyard,项目名称:pi,代码行数:14,代码来源:TemplateHelperTest.java

示例11: getGmetadConfigurationContent

import org.aspectj.util.FileUtil; //导入依赖的package包/类
public String getGmetadConfigurationContent(String host) throws Exception {
	String fileContent = null;
	String confFileName = (String) advanceConf
			.get(GangliaConstants.ClusterProperties.SERVER_CONF_FOLDER)
			+ GangliaConstants.ConfigurationFiles.GMOND_CONF;

	Map<String, Object> configValues = getConfigValueMap();

	String udpRecvChannel = "udp_recv_channel {\n port = "
			+ configValues.get("port") + " \n } ";
	configValues.put("udp_recv_channel", "/*" + udpRecvChannel + "*/");

	if (((String) advanceConf
			.get(GangliaConstants.ClusterProperties.GMETAD_HOST))
			.equals(host)) {
		confFileName = (String) advanceConf
				.get(GangliaConstants.ClusterProperties.SERVER_CONF_FOLDER)
				+ GangliaConstants.ConfigurationFiles.GMETAD_CONF;
		StringBuffer nodeIpPorts = new StringBuffer();
		// Preparing a String of nodeIp:port of gmetad node.
		nodeIpPorts
				.append(advanceConf
						.get(GangliaConstants.ClusterProperties.GMETAD_HOST))
				.append(Symbols.STR_COLON);
		nodeIpPorts.append(advanceConf
				.get(GangliaConstants.ClusterProperties.GANGLIA_PORT));
		// Putting the nodeIpsPorts string in map
		configValues.put("nodeIpsPorts", nodeIpPorts.toString());
		// On gmond nodes other than Gmetad node commenting
		// udp_recv_channel block
		configValues.put("udp_recv_channel", udpRecvChannel);
	}
	// Reading the content of the template file
	fileContent = FileUtil.readAsString(new File(confFileName));

	// Creating a string substitutor using config values map
	StrSubstitutor sub = new StrSubstitutor(configValues);

	// Replacing the config values key found in the file content with
	// respected values.
	return sub.replace(fileContent);
}
 
开发者ID:Impetus,项目名称:ankush,代码行数:43,代码来源:GangliaDeployer.java


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