本文整理了Java中org.xwiki.environment.Environment.getTemporaryDirectory()
方法的一些代码示例,展示了Environment.getTemporaryDirectory()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Environment.getTemporaryDirectory()
方法的具体详情如下:
包路径:org.xwiki.environment.Environment
类名称:Environment
方法名:getTemporaryDirectory
[英]Gets the directory for storing temporary data. The content of this directory may be deleted across restarts and thus is not a safe place to store permanent/important data.
[中]获取用于存储临时数据的目录。此目录的内容可能会在重新启动时被删除,因此不是存储永久/重要数据的安全位置。
代码示例来源:origin: org.phenotips/xwiki-platform-svg
private File getBaseTempDir()
{
File tempDir = new File(new File(this.environment.getTemporaryDirectory(), "temp"), TEMP_DIR_NAME);
return tempDir;
}
代码示例来源:origin: phenotips/phenotips
private File getBaseTempDir()
{
File tempDir = new File(new File(this.environment.getTemporaryDirectory(), "temp"), TEMP_DIR_NAME);
return tempDir;
}
代码示例来源:origin: org.xwiki.commons/xwiki-commons-extension-repository-maven
public File createTemporaryFile(String prefix, String suffix) throws IOException
{
Path filesDirectory = this.environment.getTemporaryDirectory().toPath().resolve("extension/download/files/");
Files.createDirectories(filesDirectory);
return Files.createTempFile(filesDirectory, prefix, suffix).toFile();
}
}
代码示例来源:origin: org.xwiki.commons/xwiki-commons-extension-repository-maven
@Override
public File getLocalRepository()
{
String localRepositoryPath =
this.configurationSourceProvider.get().getProperty("extension.aether.localRepository");
File directory;
if (localRepositoryPath == null) {
directory = new File(this.environment.getTemporaryDirectory(), "aether-repository");
} else {
directory = new File(localRepositoryPath);
}
return directory;
}
}
代码示例来源:origin: phenotips/phenotips
/**
* Convert a stream into a file.
*
* @param in an inputstream
* @return a File
* @throws IOException when we can't open file
*/
private File stream2file(InputStream in, String nameRoot) throws IOException
{
File tempDir = this.env.getTemporaryDirectory();
final File tempFile;
if (tempDir != null) {
tempFile = new File(tempDir, String.format("phenotips_boqa_%s.tmp", nameRoot));
} else {
tempFile = File.createTempFile("phenotips_boqa", ".tmp");
}
tempFile.deleteOnExit();
FileOutputStream out = new FileOutputStream(tempFile);
IOUtils.copy(in, out);
return tempFile;
}
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-cache-api
/**
* @return the path of the temporary local folder based on configuration identifier
*/
protected String createTempDir()
{
String path = (String) this.configuration.get(CONFX_CACHE_PATH);
if (path == null) {
File file;
if (this.environment != null) {
file = new File(this.environment.getTemporaryDirectory().getAbsolutePath(), "cache");
} else {
file = new File(System.getProperty("java.io.tmpdir"), "xwiki");
}
if (this.configuration.getConfigurationId() == null) {
file = new File(file, this.configuration.getConfigurationId());
}
if (!file.exists()) {
file.mkdirs();
}
path = file.getAbsolutePath();
}
return path;
}
代码示例来源:origin: org.xwiki.commons/xwiki-commons-cache-api
/**
* @return the path of the temporary local folder based on configuration identifier
*/
protected String createTempDir()
{
String path = (String) this.configuration.get(CONFX_CACHE_PATH);
if (path == null) {
File file;
if (this.environment != null) {
file = new File(this.environment.getTemporaryDirectory().getAbsolutePath(), "cache");
} else {
file = new File(System.getProperty("java.io.tmpdir"), "xwiki");
}
if (this.configuration.getConfigurationId() == null) {
file = new File(file, this.configuration.getConfigurationId());
}
if (!file.exists()) {
file.mkdirs();
}
path = file.getAbsolutePath();
}
return path;
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-chart-macro
/**
* Compute the location where to store the generated chart image.
*
* @param imageId the image id that we use to generate a unique storage location
* @return the location where to store the generated chart image
* @throws MacroExecutionException if an error happened when computing the location
*/
protected File getStorageLocation(ImageId imageId) throws MacroExecutionException
{
File directory;
try {
String currentWiki = URLEncoder.encode(getCurrentWiki(), DEFAULT_ENCODING);
// TODO: We need to decide if it's ok to use the the hardcoded "space/page" or if we want to use the
// current document in which case we need to extract it from the XDOM. The reason I haven't done it
// by default is because it takes more time and the image id seems unique enough to not cause collisions.
directory = new File(this.environment.getTemporaryDirectory(),
String.format("temp/%s/%s/%s/%s", MODULE_NAME, currentWiki, SPACE, PAGE));
directory.mkdirs();
} catch (Exception e) {
// Should not happen since UTF8 encoding should always be present
throw new MacroExecutionException("Failed to compute chart image location", e);
}
File locationFile = new File(directory, String.format("%s.png", imageId.getId()));
return locationFile;
}
代码示例来源:origin: org.phenotips/clinical-text-analysis-extension-biolark
new File(this.environment.getTemporaryDirectory(), "biolark_resources.jar").getAbsolutePath();
File resources = BiolarkFileUtils.downloadFile(pathToArchive, BiolarkWrapperImpl.RESOURCE_FILES_URL);
BiolarkFileUtils.extractArchive(resources, biolarkRoot);
代码示例来源:origin: phenotips/phenotips
public void loadDataFiles(String oboFileName, String associationFileName) throws InterruptedException, IOException
File workspace = new File(this.env.getTemporaryDirectory(), "ontologizer");
if (!workspace.exists()) {
workspace.mkdirs();
代码示例来源:origin: org.xwiki.commons/xwiki-commons-extension-repository-maven
Path downloadDirectory = enviroment.getTemporaryDirectory().toPath().resolve("extension/download");
Files.createDirectories(downloadDirectory);
File localDir = Files.createTempDirectory(downloadDirectory, "repository").toFile();
内容来源于网络,如有侵权,请联系作者删除!