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


Java Files类代码示例

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


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

示例1: cleanUpTmpFolder

import org.eclipse.xtext.util.Files; //导入依赖的package包/类
protected void cleanUpTmpFolder(File tempDir) {
	if (temporaryFolder == null || !temporaryFolder.isInitialized()) {
		try {
			tempDir.deleteOnExit();
			// Classloader needs .class files to lazy load an anonymous non static classes
			Files.cleanFolder(tempDir, new FileFilter() {
				@Override
				public boolean accept(File pathname) {
					boolean isClass = pathname.getName().endsWith(".class");
					if(isClass) {
						pathname.deleteOnExit();
					}
					return !isClass;
				}
			}, true, true);
		} catch (FileNotFoundException e) {
			// ignore
		}
	}
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:21,代码来源:OnTheFlyJavaCompiler.java

示例2: generateCompileScript

import org.eclipse.xtext.util.Files; //导入依赖的package包/类
/**
 * Generate the script to compile the JHipster application.
 * 
 * @param jconf Configuration of JHipster
 * @param jDirectory Directory where the script must be generated
 */
private void generateCompileScript(JhipsterConfiguration jconf, String jDirectory){
	String script = "#!/bin/bash\n\n";
	
	switch (jconf.prodDatabaseType){
	case "mysql": 	script += getMysqlScript();
	break;
	case "mongodb": script += getMongodbScript();
	break;
	case "cassandra": 	script += getCassandraScript();
	break;
	case "postgresql": 	script += getPostgreScript();
	break;
	case "mariadb":	script += getMysqlScript();
	break;
	}
	
	
	if(jconf.buildTool.equals("maven")) script+= "mvn compile";
	else script+="./gradlew compileJava";

	script += ">> compile.log 2>&1";
	Files.writeStringIntoFile(getjDirectory(jDirectory)+"compile.sh", script);
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:30,代码来源:ScriptsBuilder.java

示例3: generateBuildScript

import org.eclipse.xtext.util.Files; //导入依赖的package包/类
/**
 * Generate the script to build the application without the use of Docker.
 * 
 * @param jconf JHipster configuration to build.
 * @param jDirectory Directory where the script must be generated.
 */
private void generateBuildScript(JhipsterConfiguration jconf, String jDirectory){
	String script = "#!/bin/bash\n\n";	
	
	// TODO See if we include dev profile for all variants
	if(jconf.devDatabaseType.startsWith("h2")){
		if(jconf.buildTool.equals("maven")) script += "./mvnw -Pdev ";
		else script += "./gradlew -Pdev ";
	} else{
		if(jconf.buildTool.equals("maven")) script += "./mvnw -Pprod ";
		else script += "./gradlew -Pprod ";
	}
	
	script += ">> build.log 2>&1";
	Files.writeStringIntoFile(getjDirectory(jDirectory) + "build.sh", script);
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:22,代码来源:ScriptsBuilder.java

示例4: generateTestScript

import org.eclipse.xtext.util.Files; //导入依赖的package包/类
/**
 * Generate script used to run tests on the configuration and write it in test.sh.
 * 
 * @param jconf Configuration on which tests are run.
 * @param jDirectory Directory where to write the script.
 */
private void generateTestScript(JhipsterConfiguration jconf, String jDirectory){
	String script = "#!/bin/bash\n\n";
	Properties properties = getProperties(PROPERTIES_FILE);
	
	for(String testFramework : jconf.testFrameworks){
		switch(testFramework){
		case "gatling": 	script += properties.getProperty("removeGatlingSimulations");
							if(jconf.buildTool.equals("maven"))
								script += "./mvnw gatling:execute";
							else
								script += "printf 'empadlew gatlingRun -x cleanResources";
							script += " >> testGatling.log 2>&1\n";
							break;
		case "protractor": 	script += "xvfb-run gulp protractor >> testProtractor.log 2>&1\n";
							break;
		case "cucumber": 	if (jconf.buildTool.equals("maven")) script += "./mvnw test >> cucumber.log 2>&1\n";
							else script += "./gradlew test >> cucumber.log 2>&1\n";
		break;
		}
	}
	Files.writeStringIntoFile(getjDirectory(jDirectory)+"test.sh", script);
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:29,代码来源:ScriptsBuilder.java

示例5: generateTestDockerScript

import org.eclipse.xtext.util.Files; //导入依赖的package包/类
/**
 * Generate script used to run tests on the configuration and write it in testDocker.sh.
 * 
 * @param jconf Configuration on which tests are run.
 * @param jDirectory Directory where to write the script.
 */
private void generateTestDockerScript(JhipsterConfiguration jconf, String jDirectory){
	String script = "#!/bin/bash\n\n";
	Properties properties = getProperties(PROPERTIES_FILE);
	
	for(String testFramework : jconf.testFrameworks){
		switch(testFramework){
			case "gatling":	script += properties.getProperty("removeGatlingSimulations");
							if(jconf.buildTool.equals("maven"))
								script += "./mvnw gatling:execute";
							else
								script += "printf 'empadlew gatlingRun -x cleanResources";
							script += " >> testDockerGatling.log 2>&1\n";
							break;
		case "protractor": 	script += "xvfb-run gulp protractor >> testDockerProtractor.log 2>&1\n";
		break;
		case "cucumber": 	if (jconf.buildTool.equals("maven")) script += "./mvnw test >> cucumberDocker.log 2>&1\n";
		else script += "./gradlew test >> cucumberDocker.log 2>&1\n";
		break;
		}
	}
	Files.writeStringIntoFile(getjDirectory(jDirectory)+"testDocker.sh", script);
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:29,代码来源:ScriptsBuilder.java

示例6: getClientAppJson

import org.eclipse.xtext.util.Files; //导入依赖的package包/类
/**
 * Returns all yo-rc.json templates related to the clientApp.
 * All these templates must be located in: yo-rc-templates/ and start with clientApp
 * 
 * @return yo-rc.json Templates as JsonObject
 */
public JsonObject[] getClientAppJson(){
	int i = 0;
	JsonParser jsonParser = new JsonParser();
	if (clientAppJson == null){
		clientAppJson = new JsonObject[2];
		for(final File file:new File(YO_RC_DIRECTORY).listFiles()){
			if(file.getName().startsWith("clientApp")){ 
				JsonObject object = jsonParser.parse(Files.readFileIntoString(YO_RC_DIRECTORY+file.getName())).getAsJsonObject();
				clientAppJson[i] = object;
				i++;
			}
		}
	}
	return clientAppJson;
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:22,代码来源:JsonChecker.java

示例7: getServerAppJson

import org.eclipse.xtext.util.Files; //导入依赖的package包/类
/**
 * Returns all yo-rc.json templates related to the serverApp.
 * All these templates must be located in: yo-rc-templates/ and start with serverApp 
 * 
 * @return
 */
public JsonObject[] getServerAppJson(){
	int i = 0;
	JsonParser jsonParser = new JsonParser();
	if(serverAppJson == null){
		serverAppJson = new JsonObject[4];
		for(final File file:new File(YO_RC_DIRECTORY).listFiles()){
			if(file.getName().startsWith("serverApp")){
				JsonObject object= jsonParser.parse(Files.readFileIntoString(YO_RC_DIRECTORY+file.getName())).getAsJsonObject();
				serverAppJson[i] = object;
				i++;
			}
		}
	}
	return serverAppJson;
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:22,代码来源:JsonChecker.java

示例8: checkGenerateApp

import org.eclipse.xtext.util.Files; //导入依赖的package包/类
/**
 * Check the App is generated successfully
 * 
 * @param file Name to check
 * @return true if the app is well generated
 */
public boolean checkGenerateApp(String fileName){

	try{
	//extract log
	String text = Files.readFileIntoString(path +fileName);

	//CHECK IF Server app generated successfully.
	//OR Client app generated successfully.
	Matcher m = Pattern.compile("((.*?)Server app generated successfully.)").matcher(text);
	Matcher m2 = Pattern.compile("((.*?)Client app generated successfully.)").matcher(text);

	while(m.find() | m2.find()) return true; 
	return false;
	} catch (Exception e){
		return false;
	}
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:24,代码来源:ResultChecker.java

示例9: checkCompileApp

import org.eclipse.xtext.util.Files; //导入依赖的package包/类
/**
 * Check the App is compiled successfully
 * 
 * @param file Name to check
 * @return true if the app is well compiled
 */
public boolean checkCompileApp(String fileName) throws FileNotFoundException{

	try{
	//extract log
	String text = Files.readFileIntoString(path + fileName);

	//CHECK IF BUILD FAILED THEN false
	Matcher m1 = Pattern.compile("((.*?)BUILD FAILED)").matcher(text);
	Matcher m2 = Pattern.compile("((.*?)BUILD FAILURE)").matcher(text);

	while(m1.find() | m2.find()) return false;
	return true;
	} catch (Exception e){
		return false;
	}
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:23,代码来源:ResultChecker.java

示例10: checkBuildApp

import org.eclipse.xtext.util.Files; //导入依赖的package包/类
/**
 * Check the App is build successfully
 * 
 * @param jDirectory Name of the folder
 */
public boolean checkBuildApp(String fileName){
	try{
		String text = Files.readFileIntoString(path+fileName);

		//CHECK IF BUILD FAILED THEN false
		Matcher m = Pattern.compile("((.*?)APPLICATION FAILED TO START)").matcher(text);
		Matcher m2 = Pattern.compile("((.*?)BUILD FAILED)").matcher(text);
		Matcher m3 = Pattern.compile("((.*?)BUILD FAILURE)").matcher(text);

		while(m.find() | m2.find() | m3.find()) return false;
		return true;
	} catch (Exception e){
		return false;
	}
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:21,代码来源:ResultChecker.java

示例11: extractCoverageIntstructions

import org.eclipse.xtext.util.Files; //导入依赖的package包/类
/**
 * Return coverageInstructions from Jacoco
 * 
 * @param jDirectory Name of the folder
 * @return String coverage of instructions
 * 
 */
public String extractCoverageIntstructions(String fileName){
	String resultsTests = DEFAULT_NOT_FOUND_VALUE;
	try{
		_log.info("ça passe !");
		String text = Files.readFileIntoString(path+JACOCOPATH+fileName);

		Matcher m1 = Pattern.compile("Total</td><td class=\"bar\">(.*?)</td><td class=\"ctr2\">(.*?) %"
				+ "</td><td class=\"bar\">(.*?)</td><td class=\"ctr2\">(.*?) %</td>").matcher(text);
		
		Matcher m2 = Pattern.compile("Total</td><td class=\"bar\">(.*?)</td><td class=\"ctr2\">(.*?)%"
				+ "</td><td class=\"bar\">(.*?)</td><td class=\"ctr2\">(.*?)%</td>").matcher(text);
		
		while(m1.find()) return resultsTests = m1.group(2).toString();
		while(m2.find()) return resultsTests = m2.group(2).toString();
	} catch (Exception e){
		_log.error("Exception: "+e.getMessage());
	}
	return resultsTests;
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:27,代码来源:ResultChecker.java

示例12: extractCoverageBranches

import org.eclipse.xtext.util.Files; //导入依赖的package包/类
/**
 * Return coverageBranches from Jacoco
 * 
 * @param jDirectory Name of the folder
 * @return String coverage of Branches
 * 
 */
public String extractCoverageBranches(String fileName){
	String resultsTests = DEFAULT_NOT_FOUND_VALUE;
	try{
		String text = Files.readFileIntoString(path+JACOCOPATH+fileName);

		Matcher m1 = Pattern.compile("Total</td><td class=\"bar\">(.*?)</td><td class=\"ctr2\">(.*?) %"
				+ "</td><td class=\"bar\">(.*?)</td><td class=\"ctr2\">(.*?) %</td>").matcher(text);
		Matcher m2 = Pattern.compile("Total</td><td class=\"bar\">(.*?)</td><td class=\"ctr2\">(.*?)%"
				+ "</td><td class=\"bar\">(.*?)</td><td class=\"ctr2\">(.*?)%</td>").matcher(text);

		while(m1.find()) return resultsTests = m1.group(4).toString();
		while(m2.find()) return resultsTests = m2.group(4).toString();
	} catch (Exception e){
		_log.error("Exception: "+e.getMessage());
	}
	return resultsTests;
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:25,代码来源:ResultChecker.java

示例13: extractJSCoverageStatements

import org.eclipse.xtext.util.Files; //导入依赖的package包/类
/**
 * Retrieves the percentage of Javascript Statements Coverage
 * 
 * @param fileName File containing the percentage. 
 * @return The percentage of Statement Coverage (Javascript)
 */
public String extractJSCoverageStatements(String fileName){
	String result = DEFAULT_NOT_FOUND_VALUE;
	try{
		String text = Files.readFileIntoString(path+fileName);
		Matcher m1 = Pattern.compile("(.*?)<div class='fl pad1y space-right2'>(\r*?)(\n*?)"
									+ "(.*?)<span class=\"strong\">(.*?)</span>(\r*?)(\n*?)"
									+ "(.*?)<span class=\"quiet\">Statements</span>(\r*?)(\n*?)"
									+ "(.*?)<span class='fraction'>(.*?)</span>(\r*?)(\n*?)"
									+ "(.*?)</div>").matcher(text);
		while(m1.find()) return m1.group(5).toString();
	} catch(Exception e){
		_log.error("Exception: "+e.getMessage());
	}
	return result;
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:22,代码来源:ResultChecker.java

示例14: extractJSCoverageBranches

import org.eclipse.xtext.util.Files; //导入依赖的package包/类
/**
 * Retrieves the percentage of Javascript Branches Coverage
 * 
 * @param fileName File containing the percentage.
 * @return The percentage of Branches Coverage (Javascript)
 */
public String extractJSCoverageBranches(String fileName){
	String result = DEFAULT_NOT_FOUND_VALUE;
	try{
		String text = Files.readFileIntoString(path+fileName);
		Matcher m1 = Pattern.compile("(.*?)<div class='fl pad1y space-right2'>(\r*?)(\n*?)"
									+ "(.*?)<span class=\"strong\">(.*?)</span>(\r*?)(\n*?)"
									+ "(.*?)<span class=\"quiet\">Branches</span>(\r*?)(\n*?)"
									+ "(.*?)<span class='fraction'>(.*?)</span>(\r*?)(\n*?)"
									+ "(.*?)</div>").matcher(text);
		while(m1.find()) return m1.group(5).toString();
	} catch(Exception e){
		_log.error("Exception: "+e.getMessage());
	}
	return result;
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:22,代码来源:ResultChecker.java

示例15: extractStacktraces

import org.eclipse.xtext.util.Files; //导入依赖的package包/类
/**
 * Return stacktraces
 * 
 * @param jDirectory Name of the folder
 * @return String of stacktraces
 * 
 */
public String extractStacktraces(String fileName){
	String stacktraces = "";
	try{		
		String text = Files.readFileIntoString(path+fileName);

		Matcher m1 = Pattern.compile("(Exception(.*?)\\n)").matcher(text);
		Matcher m2 = Pattern.compile("(Caused by(.*?)\\n)").matcher(text);
		Matcher m3 = Pattern.compile("((.*?)\\[ERROR\\](.*))").matcher(text);
		Matcher m4 = Pattern.compile("(ERROR:(.*?)\\n)").matcher(text);
		Matcher m5 = Pattern.compile("(error:(.*?)^)").matcher(text);
		Matcher m6 = Pattern.compile("(Error parsing reference:(.*?) is not a valid repository/tag)").matcher(text);

		while(m1.find()) stacktraces = stacktraces + m1.group().toString() + "\n";
		while(m2.find()) stacktraces = stacktraces + m2.group().toString() + "\n";
		while(m3.find()) stacktraces = stacktraces + m3.group().toString() + "\n";
		while(m4.find()) stacktraces = stacktraces + m4.group().toString() + "\n";
		while(m5.find()) stacktraces = stacktraces + m5.group().toString() + "\n";
		while(m6.find()) stacktraces = stacktraces + m6.group(1).toString() + "\n";
	} catch (Exception e){
		_log.error("Exception: "+e.getMessage());
	}
	return stacktraces;
}
 
开发者ID:axel-halin,项目名称:Thesis-JHipster,代码行数:31,代码来源:ResultChecker.java


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