com.intellij.openapi.util.io.FileUtil.createTempDirectory()方法的使用及代码示例

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

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

FileUtil.createTempDirectory介绍

暂无

代码示例

代码示例来源:origin: KronicDeth/intellij-elixir

protected File doGetProjectDir() throws IOException{
 return FileUtil.createTempDirectory("prj", null);
}

代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin

private VirtualFile createGoPath() throws IOException {
 VirtualFile goPath = VfsUtil.findFileByIoFile(FileUtil.createTempDirectory("go", "path"), true);
 tempRootsToClean.add(goPath);
 return goPath;
}

代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin

private static File createDir(String... children) {
  try {
   File dir = FileUtil.createTempDirectory("goSdk", "test");
   for (String child : children) {
    File file = new File(dir, child);
    FileUtil.createParentDirs(file);
    if (StringUtil.endsWithChar(child, '/')) {
     assertTrue(file.mkdir());
    }
    else {
     assertTrue(file.createNewFile());
    }
   }
   return dir;
  }
  catch (IOException e) {
   throw new RuntimeException(e);
  }
 }
}

代码示例来源:origin: KronicDeth/intellij-elixir

@Override
protected void setUp() throws Exception {
 super.setUp();
 myModel = JpsElementFactory.getInstance().createModel();
 myProject = myModel.getProject();
 myDataStorageRoot = FileUtil.createTempDirectory("compile-server-" + getProjectName(), null);
 myLogger = new TestProjectBuilderLogger();
 myBuildParams = new HashMap<String, String>();
}

代码示例来源:origin: zalando/intellij-swagger

@NotNull
private File copySwaggerUiToTempDir() throws IOException, URISyntaxException {
 final ClassLoader classLoader = getClass().getClassLoader();
 final File file = new File(classLoader.getResource(SWAGGER_UI_FOLDER_NAME).toURI());
 final File tempSwaggerUiDir = FileUtil.createTempDirectory(SWAGGER_UI_FOLDER_NAME, "", true);
 FileUtil.copyDirContent(file, tempSwaggerUiDir);
 return tempSwaggerUiDir;
}

代码示例来源:origin: GoogleCloudPlatform/google-cloud-intellij

@Override
public Path createStagingDirectory(LoggingHandler loggingHandler, String cloudProjectName)
  throws IOException {
 Path stagingDirectory =
   FileUtil.createTempDirectory(
       "gae-staging-" + cloudProjectName /* prefix */,
       null /* suffix */,
       true /* deleteOnExit */)
     .toPath();
 loggingHandler.print(
   "Created temporary staging directory: " + stagingDirectory.toString() + "\n");
 return stagingDirectory;
}

代码示例来源:origin: GoogleCloudPlatform/google-cloud-intellij

/**
 * Creates all directories, represented as {@link File Files}, annotated with {@link
 * TestDirectory}.
 */
private void createTestDirectories() throws IllegalAccessException, IOException {
 for (Field field : getFieldsWithAnnotation(testInstance.getClass(), TestDirectory.class)) {
  field.setAccessible(true);
  if (!field.getType().equals(File.class)) {
   throw new IllegalArgumentException(
     "@TestDirectory can only annotate fields of type java.io.File");
  }
  TestDirectory annotation = field.getAnnotation(TestDirectory.class);
  File directory = FileUtil.createTempDirectory(annotation.name(), null);
  filesToDelete.add(directory);
  field.set(testInstance, directory);
 }
}

代码示例来源:origin: GoogleCloudPlatform/google-cloud-intellij

/**
 * Creates all {@link File files} annotated with {@link TestFile} in the given directory name.
 *
 * @param directoryName the name of the directory to create the test files in
 */
private void createTestFiles(String directoryName) throws IllegalAccessException, IOException {
 for (Field field : getFieldsWithAnnotation(testInstance.getClass(), TestFile.class)) {
  field.setAccessible(true);
  if (!field.getType().equals(File.class)) {
   throw new IllegalArgumentException(
     "@TestFile can only annotate fields of type java.io.File");
  }
  TestFile annotation = field.getAnnotation(TestFile.class);
  File directory = FileUtil.createTempDirectory(directoryName, null);
  File file = new File(directory, annotation.name());
  if (!file.createNewFile()) {
   throw new IOException("Can't create file: " + file);
  }
  if (!annotation.contents().isEmpty()) {
   FileUtil.writeToFile(file, annotation.contents());
  }
  filesToDelete.add(file);
  field.set(testInstance, file);
 }
}

代码示例来源:origin: GoogleCloudPlatform/google-cloud-intellij

protected void testConvert(String testDataPath) throws IOException {
  // setup test data
  File testDataRoot = new File(AppEngineCodeInsightTestCase.getTestDataPath(), testDataPath);
  File testData = new File(testDataRoot, BEFORE_PATH);
  File tempDir = FileUtil.createTempDirectory(testDataPath, null);
  FileUtil.copyDir(testData, tempDir);
  File expectedDataDir = new File(testDataRoot, AFTER_PATH);

  // run the conversion operation
  ProjectConversionTestUtil.convert(tempDir.getAbsolutePath());

  PlatformTestUtil.assertDirectoriesEqual(
    LocalFileSystem.getInstance().refreshAndFindFileByIoFile(expectedDataDir),
    LocalFileSystem.getInstance().refreshAndFindFileByIoFile(tempDir),
    new VirtualFileFilter() {
     @Override
     public boolean accept(VirtualFile file) {
      // ignore any generated backup files
      return !file.getName().startsWith(ProjectConversionUtil.PROJECT_FILES_BACKUP);
     }
    });
 }
}

相关文章