org.xwiki.environment.Environment.getTemporaryDirectory()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(5.6k)|赞(0)|评价(0)|浏览(103)

本文整理了Java中org.xwiki.environment.Environment.getTemporaryDirectory()方法的一些代码示例,展示了Environment.getTemporaryDirectory()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Environment.getTemporaryDirectory()方法的具体详情如下:
包路径:org.xwiki.environment.Environment
类名称:Environment
方法名:getTemporaryDirectory

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

  1. private File getBaseTempDir()
  2. {
  3. File tempDir = new File(new File(this.environment.getTemporaryDirectory(), "temp"), TEMP_DIR_NAME);
  4. return tempDir;
  5. }

代码示例来源:origin: phenotips/phenotips

  1. private File getBaseTempDir()
  2. {
  3. File tempDir = new File(new File(this.environment.getTemporaryDirectory(), "temp"), TEMP_DIR_NAME);
  4. return tempDir;
  5. }

代码示例来源:origin: org.xwiki.commons/xwiki-commons-extension-repository-maven

  1. public File createTemporaryFile(String prefix, String suffix) throws IOException
  2. {
  3. Path filesDirectory = this.environment.getTemporaryDirectory().toPath().resolve("extension/download/files/");
  4. Files.createDirectories(filesDirectory);
  5. return Files.createTempFile(filesDirectory, prefix, suffix).toFile();
  6. }
  7. }

代码示例来源:origin: org.xwiki.commons/xwiki-commons-extension-repository-maven

  1. @Override
  2. public File getLocalRepository()
  3. {
  4. String localRepositoryPath =
  5. this.configurationSourceProvider.get().getProperty("extension.aether.localRepository");
  6. File directory;
  7. if (localRepositoryPath == null) {
  8. directory = new File(this.environment.getTemporaryDirectory(), "aether-repository");
  9. } else {
  10. directory = new File(localRepositoryPath);
  11. }
  12. return directory;
  13. }
  14. }

代码示例来源:origin: phenotips/phenotips

  1. /**
  2. * Convert a stream into a file.
  3. *
  4. * @param in an inputstream
  5. * @return a File
  6. * @throws IOException when we can't open file
  7. */
  8. private File stream2file(InputStream in, String nameRoot) throws IOException
  9. {
  10. File tempDir = this.env.getTemporaryDirectory();
  11. final File tempFile;
  12. if (tempDir != null) {
  13. tempFile = new File(tempDir, String.format("phenotips_boqa_%s.tmp", nameRoot));
  14. } else {
  15. tempFile = File.createTempFile("phenotips_boqa", ".tmp");
  16. }
  17. tempFile.deleteOnExit();
  18. FileOutputStream out = new FileOutputStream(tempFile);
  19. IOUtils.copy(in, out);
  20. return tempFile;
  21. }
  22. }

代码示例来源:origin: org.xwiki.platform/xwiki-platform-cache-api

  1. /**
  2. * @return the path of the temporary local folder based on configuration identifier
  3. */
  4. protected String createTempDir()
  5. {
  6. String path = (String) this.configuration.get(CONFX_CACHE_PATH);
  7. if (path == null) {
  8. File file;
  9. if (this.environment != null) {
  10. file = new File(this.environment.getTemporaryDirectory().getAbsolutePath(), "cache");
  11. } else {
  12. file = new File(System.getProperty("java.io.tmpdir"), "xwiki");
  13. }
  14. if (this.configuration.getConfigurationId() == null) {
  15. file = new File(file, this.configuration.getConfigurationId());
  16. }
  17. if (!file.exists()) {
  18. file.mkdirs();
  19. }
  20. path = file.getAbsolutePath();
  21. }
  22. return path;
  23. }

代码示例来源:origin: org.xwiki.commons/xwiki-commons-cache-api

  1. /**
  2. * @return the path of the temporary local folder based on configuration identifier
  3. */
  4. protected String createTempDir()
  5. {
  6. String path = (String) this.configuration.get(CONFX_CACHE_PATH);
  7. if (path == null) {
  8. File file;
  9. if (this.environment != null) {
  10. file = new File(this.environment.getTemporaryDirectory().getAbsolutePath(), "cache");
  11. } else {
  12. file = new File(System.getProperty("java.io.tmpdir"), "xwiki");
  13. }
  14. if (this.configuration.getConfigurationId() == null) {
  15. file = new File(file, this.configuration.getConfigurationId());
  16. }
  17. if (!file.exists()) {
  18. file.mkdirs();
  19. }
  20. path = file.getAbsolutePath();
  21. }
  22. return path;
  23. }

代码示例来源:origin: org.xwiki.platform/xwiki-platform-chart-macro

  1. /**
  2. * Compute the location where to store the generated chart image.
  3. *
  4. * @param imageId the image id that we use to generate a unique storage location
  5. * @return the location where to store the generated chart image
  6. * @throws MacroExecutionException if an error happened when computing the location
  7. */
  8. protected File getStorageLocation(ImageId imageId) throws MacroExecutionException
  9. {
  10. File directory;
  11. try {
  12. String currentWiki = URLEncoder.encode(getCurrentWiki(), DEFAULT_ENCODING);
  13. // TODO: We need to decide if it's ok to use the the hardcoded "space/page" or if we want to use the
  14. // current document in which case we need to extract it from the XDOM. The reason I haven't done it
  15. // by default is because it takes more time and the image id seems unique enough to not cause collisions.
  16. directory = new File(this.environment.getTemporaryDirectory(),
  17. String.format("temp/%s/%s/%s/%s", MODULE_NAME, currentWiki, SPACE, PAGE));
  18. directory.mkdirs();
  19. } catch (Exception e) {
  20. // Should not happen since UTF8 encoding should always be present
  21. throw new MacroExecutionException("Failed to compute chart image location", e);
  22. }
  23. File locationFile = new File(directory, String.format("%s.png", imageId.getId()));
  24. return locationFile;
  25. }

代码示例来源:origin: org.phenotips/clinical-text-analysis-extension-biolark

  1. new File(this.environment.getTemporaryDirectory(), "biolark_resources.jar").getAbsolutePath();
  2. File resources = BiolarkFileUtils.downloadFile(pathToArchive, BiolarkWrapperImpl.RESOURCE_FILES_URL);
  3. BiolarkFileUtils.extractArchive(resources, biolarkRoot);

代码示例来源:origin: phenotips/phenotips

  1. public void loadDataFiles(String oboFileName, String associationFileName) throws InterruptedException, IOException
  2. File workspace = new File(this.env.getTemporaryDirectory(), "ontologizer");
  3. if (!workspace.exists()) {
  4. workspace.mkdirs();

代码示例来源:origin: org.xwiki.commons/xwiki-commons-extension-repository-maven

  1. Path downloadDirectory = enviroment.getTemporaryDirectory().toPath().resolve("extension/download");
  2. Files.createDirectories(downloadDirectory);
  3. File localDir = Files.createTempDirectory(downloadDirectory, "repository").toFile();

相关文章