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


Java LpeFileUtils类代码示例

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


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

示例1: updateTabs

import org.lpe.common.util.LpeFileUtils; //导入依赖的package包/类
private void updateTabs()
{
	if (!SpotterClientController.getController(this.resultAlternative.getProject()).isConnected())
		return;

	if (resultsContainer == null) {
		IFile file = resultAlternative.getResource()
				.getFile(ResultsLocationConstants.RESULTS_SERIALIZATION_FILE_NAME);
		if (!file.exists())
			return;

		try {
			resultsContainer = (ResultsContainer) LpeFileUtils.readObject(file.getLocation().toFile());
			updateHierarchy();
			updateReport();
		} catch (ClassNotFoundException | IOException e) {
			e.printStackTrace();
		}
	}
}
 
开发者ID:CloudScale-Project,项目名称:Environment,代码行数:21,代码来源:ResultAlternativeComposite.java

示例2: createDynamicSpotterConfiguration

import org.lpe.common.util.LpeFileUtils; //导入依赖的package包/类
/**
 * Creates necessary configuration files for the diagnosis from the given
 * job description.
 * 
 * @param jobId
 *            the job id of the diagnosis
 * @param jobDescription
 *            the job description which holds the configuration information
 * @return the path to the DS configuration file which is required by DS
 */
private String createDynamicSpotterConfiguration(long jobId, JobDescription jobDescription) {
	FileManager fileManager = FileManager.getInstance();
	String location = getRuntimeLocation() + "/" + jobId;
	LpeFileUtils.createDir(location);
	String configurationFile = null;

	try {
		fileManager.writeEnvironmentConfig(location, jobDescription.getMeasurementEnvironment());
		fileManager.writeHierarchyConfig(location, jobDescription.getHierarchy());
		configurationFile = fileManager.writeSpotterConfig(location, jobDescription.getDynamicSpotterConfig());
		LOGGER.info("Storing configuration for diagnosis run #" + jobId + " in " + location);
	} catch (IOException | JAXBException e) {
		String message = "Failed to create DS configuration.";
		LOGGER.error(message, e);
		throw new RuntimeException(message, e);
	}

	return configurationFile;
}
 
开发者ID:sopeco,项目名称:DynamicSpotter,代码行数:30,代码来源:SpotterServiceWrapper.java

示例3: unpackFromInputStream

import org.lpe.common.util.LpeFileUtils; //导入依赖的package包/类
private boolean unpackFromInputStream(String jobId, File runFolder, String zipFileName, InputStream resultsZipStream) {
	try {
		runFolder.mkdir();
		FileOutputStream fos = new FileOutputStream(zipFileName);
		LpeStreamUtils.pipe(resultsZipStream, fos);

		resultsZipStream.close();

		File zipFile = new File(zipFileName);
		LpeFileUtils.unzip(zipFile, runFolder);
		zipFile.delete();

		return true;
	} catch (Exception e) {
		String message = "Error while saving fetched results for job " + jobId + "!";
		DialogUtils.handleError(message, e);
		LOGGER.error(message, e);
	}

	return false;
}
 
开发者ID:sopeco,项目名称:DynamicSpotter,代码行数:22,代码来源:SpotterProjectResults.java

示例4: getAdditionalResourcesPath

import org.lpe.common.util.LpeFileUtils; //导入依赖的package包/类
/**
 * Returns the path for additional resources.
 * 
 * @return directory where additional resources shall be stored
 */
public String getAdditionalResourcesPath() {
	StringBuilder pathBuilder = new StringBuilder();
	if (resourcePath == null) {
		pathBuilder.append(GlobalConfiguration.getInstance().getProperty(ConfigKeys.RESULT_DIR));
		pathBuilder.append(getControllerIdentifier());
		pathBuilder.append(System.getProperty("file.separator"));

		pathBuilder.append(ResultsLocationConstants.RESULT_RESOURCES_SUB_DIR);
		pathBuilder.append(System.getProperty("file.separator"));

		resourcePath = pathBuilder.toString();
		File file = new File(resourcePath);
		if (!file.exists()) {
			LpeFileUtils.createDir(resourcePath);
		}
	} else {
		pathBuilder.append(resourcePath);
	}

	return pathBuilder.toString();
}
 
开发者ID:sopeco,项目名称:DynamicSpotter,代码行数:27,代码来源:DetectionResultManager.java

示例5: storeScriptFile

import org.lpe.common.util.LpeFileUtils; //导入依赖的package包/类
private String storeScriptFile(String script) {
	String scriptFile = LpeFileUtils.concatFileName(LpeSystemUtils.getSystemTempDir(), DYNAMIC_SPOTTER_DIR);
	scriptFile = LpeFileUtils.concatFileName(scriptFile, "chartTmp");
	scriptFile = LpeFileUtils.concatFileName(scriptFile, "script-" + seriesCounter + ".r");
	try {
		FileWriter fWriter = new FileWriter(scriptFile, false);
		fWriter.append(script);
		fWriter.flush();

		fWriter.close();
	} catch (IOException e1) {
		// TODO Auto-generated catch block
		e1.printStackTrace();
	}
	return scriptFile;
}
 
开发者ID:sopeco,项目名称:DynamicSpotter,代码行数:17,代码来源:RChartBuilder.java

示例6: createTempDir

import org.lpe.common.util.LpeFileUtils; //导入依赖的package包/类
private static void createTempDir() throws IOException {
	tempDir = new File("tempJUnit");
	if (tempDir.exists()) {
		LpeFileUtils.removeDir(tempDir.getAbsolutePath());
	}
	LpeFileUtils.createDir(tempDir.getAbsolutePath());
	newFileName = tempDir.getAbsolutePath() + System.getProperty("file.separator") + "newFile.txt";
	File newFile = new File(newFileName);
	newFile.createNewFile();

	hierarchyFileName = tempDir.getAbsolutePath() + System.getProperty("file.separator") + "hierarchy.xml";
	newFile = new File(hierarchyFileName);
	newFile.createNewFile();

	mEnvFileName = tempDir.getAbsolutePath() + System.getProperty("file.separator") + "menv.xml";
	newFile = new File(mEnvFileName);
	newFile.createNewFile();

	wrongFileName = tempDir.getAbsolutePath() + System.getProperty("file.separator") + "wrong.xml";
}
 
开发者ID:sopeco,项目名称:DynamicSpotter,代码行数:21,代码来源:ConfigCheckTest.java

示例7: fetchResults

import org.lpe.common.util.LpeFileUtils; //导入依赖的package包/类
public static void fetchResults(ResultAlternative alternative, Long jobId)
{
	ServiceClientWrapper client = SpotterClientController.getController(alternative.getProject()).getClient();

	FileOutputStream fos;
	try
	{
		InputStream resultsZipStream = client.requestResults(jobId.toString());
		if (resultsZipStream == null || resultsZipStream.available() == 0)
		{
			String msg = "Received empty input stream for job " + jobId + ", skipping job!";
			DialogUtils.openWarning(msg);
		}

		File zipFile = alternative.getResource().getFile("temp.zip").getLocation().toFile();
		zipFile.createNewFile();
		fos = new FileOutputStream(zipFile);
		LpeStreamUtils.pipe(resultsZipStream, fos);
		resultsZipStream.close();

		LpeFileUtils.unzip(zipFile, alternative.getResource().getLocation().toFile());
		zipFile.delete();
		alternative.getResource().refreshLocal(IResource.DEPTH_INFINITE, null);

	} catch (Exception e)
	{
		String message = "Error while saving fetched results for job " + jobId + "!";
		DialogUtils.handleError(message, e);
		logger.severe(message);
		e.printStackTrace();
	}
}
 
开发者ID:CloudScale-Project,项目名称:Environment,代码行数:33,代码来源:Util.java

示例8: getZippedRunFolder

import org.lpe.common.util.LpeFileUtils; //导入依赖的package包/类
private FileInputStream getZippedRunFolder(String path) throws FileNotFoundException {
	String zipFileName = path + ZIP_FILE_EXTENSION;
	File zipFile = new File(zipFileName);
	File source = new File(path);

	if (!zipFile.exists()) {
		LOGGER.debug("Packing main results data from '{}' ...", path);

		FileFilter fileFilter = new FileFilter() {

			@Override
			public boolean accept(File pathname) {
				if (pathname.isFile()) {
					return true;
				}

				if (pathname.isDirectory() && !pathname.getName().equals(ResultsLocationConstants.CSV_SUB_DIR)) {
					return true;
				}

				return false;
			}
		};

		LpeFileUtils.zip(source, zipFile, fileFilter);
		LOGGER.debug("Results data packed!");
	}

	FileInputStream fis = new FileInputStream(zipFileName);

	return fis;
}
 
开发者ID:sopeco,项目名称:DynamicSpotter,代码行数:33,代码来源:SpotterServiceWrapper.java

示例9: createTempDir

import org.lpe.common.util.LpeFileUtils; //导入依赖的package包/类
private static void createTempDir() throws IOException {
	tempDir = new File("tempJUnit");
	if (tempDir.exists()) {
		LpeFileUtils.removeDir(tempDir.getAbsolutePath());
	}
	LpeFileUtils.createDir(tempDir.getAbsolutePath());
}
 
开发者ID:sopeco,项目名称:DynamicSpotter,代码行数:8,代码来源:SpotterServiceTest.java

示例10: readResultsContainer

import org.lpe.common.util.LpeFileUtils; //导入依赖的package包/类
/**
 * Reads the results container within the given result folder. In case of
 * failure <code>null</code> will be returned.
 * 
 * @param resultFolder
 *            the result folder to read from
 * @return the read container or <code>null</code>
 */
public static ResultsContainer readResultsContainer(IFolder resultFolder) {
	IFile resFile = resultFolder.getFile(ResultsLocationConstants.RESULTS_SERIALIZATION_FILE_NAME);
	ResultsContainer resultsContainer = null;
	File containerFile = new File(resFile.getLocation().toString());
	if (containerFile.exists()) {
		try {
			resultsContainer = (ResultsContainer) LpeFileUtils.readObject(containerFile);
		} catch (ClassNotFoundException | IOException e) {
			LOGGER.debug("Cannot read results container " + containerFile);
		}
	}
	return resultsContainer;
}
 
开发者ID:sopeco,项目名称:DynamicSpotter,代码行数:22,代码来源:SpotterUtils.java

示例11: writeResultsContainer

import org.lpe.common.util.LpeFileUtils; //导入依赖的package包/类
/**
 * Writes the container to the given result folder.
 * 
 * @param resultFolder
 *            the result folder to write to
 * @param container
 *            the container to be written
 * @return <code>true</code> on success, <code>false</code> otherwise
 */
public static boolean writeResultsContainer(IFolder resultFolder, ResultsContainer container) {
	IFile resFile = resultFolder.getFile(ResultsLocationConstants.RESULTS_SERIALIZATION_FILE_NAME);
	File containerFile = new File(resFile.getLocation().toString());
	try {
		LpeFileUtils.writeObject(containerFile.getAbsolutePath(), container);
	} catch (IOException e) {
		String message = "Error while writing results container!";
		LOGGER.error(message, e);
		DialogUtils.handleError(message, e);
		return false;
	}
	return true;
}
 
开发者ID:sopeco,项目名称:DynamicSpotter,代码行数:23,代码来源:SpotterUtils.java

示例12: readJobsContainer

import org.lpe.common.util.LpeFileUtils; //导入依赖的package包/类
/**
 * Retrieves the current job container for the given project. In case the
 * file does not exist or an error occurs while reading it an empty
 * container is returned.
 * 
 * @param project
 *            the project the container should be retrieved for
 * @return the corresponding job container or an empty one
 */
public static JobsContainer readJobsContainer(IProject project) {
	String fileName = project.getFile(FileManager.JOBS_CONTAINER_FILENAME).getLocation().toString();
	File file = new File(fileName);
	JobsContainer jobsContainer = new JobsContainer();
	if (file.exists()) {
		try {
			jobsContainer = (JobsContainer) LpeFileUtils.readObject(file);
		} catch (ClassNotFoundException | IOException e) {
			LOGGER.warn("JobsContainer {} corrupted, ignoring file contents. Error: {}", fileName, e.getMessage());
		}
	}
	return jobsContainer;
}
 
开发者ID:sopeco,项目名称:DynamicSpotter,代码行数:23,代码来源:JobsContainer.java

示例13: writeJobsContainer

import org.lpe.common.util.LpeFileUtils; //导入依赖的package包/类
private static boolean writeJobsContainer(IProject project, JobsContainer jobsContainer) {
	String fileName = project.getFile(FileManager.JOBS_CONTAINER_FILENAME).getLocation().toString();
	try {
		LpeFileUtils.writeObject(fileName, jobsContainer);
		return true;
	} catch (IOException e) {
		LOGGER.error("Error while writing JobsContainer.", e);
	}
	return false;
}
 
开发者ID:sopeco,项目名称:DynamicSpotter,代码行数:11,代码来源:JobsContainer.java

示例14: extractCopy

import org.lpe.common.util.LpeFileUtils; //导入依赖的package包/类
private void extractCopy(String targetFile, String scriptStr) {
	String fileName = targetFile.substring(targetFile.lastIndexOf("/") + 1, targetFile.lastIndexOf("."));
	String targetDir = targetFile.substring(0, targetFile.lastIndexOf("/"));

	targetDir = LpeFileUtils.concatFileName(targetDir, "chartData");
	targetDir = LpeFileUtils.concatFileName(targetDir, fileName);
	targetDir = targetDir.replace(System.getProperty("file.separator"), "/");
	LpeFileUtils.createDir(targetDir);
	copyCSVs(targetDir);

	String originalDir = LpeFileUtils.concatFileName(
			LpeFileUtils.concatFileName(LpeSystemUtils.getSystemTempDir(), DYNAMIC_SPOTTER_DIR), "chartTmp")
			.replace(System.getProperty("file.separator"), "/");
	scriptStr = scriptStr.replace(originalDir, targetDir);

	String scriptFile = LpeFileUtils.concatFileName(targetDir, "script-" + seriesCounter + ".r");
	try {
		FileWriter fWriter = new FileWriter(scriptFile, false);
		fWriter.append(scriptStr);
		fWriter.flush();

		fWriter.close();
	} catch (IOException e1) {
		// TODO Auto-generated catch block
		e1.printStackTrace();
	}

}
 
开发者ID:sopeco,项目名称:DynamicSpotter,代码行数:29,代码来源:RChartBuilder.java

示例15: copyCSVs

import org.lpe.common.util.LpeFileUtils; //导入依赖的package包/类
private void copyCSVs(String target) {
	LpeFileUtils.createDir(target);

	String dir = LpeFileUtils.concatFileName(LpeSystemUtils.getSystemTempDir(), DYNAMIC_SPOTTER_DIR);
	dir = LpeFileUtils.concatFileName(dir, "chartTmp");
	try {
		LpeFileUtils.copyDirectory(dir, target);
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
开发者ID:sopeco,项目名称:DynamicSpotter,代码行数:13,代码来源:RChartBuilder.java


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