本文整理汇总了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;
}
示例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);
}
示例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
}
示例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;
}
示例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);
}
示例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;
}
示例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());
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}