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


Java FileUtil.sanitizeFileName方法代码示例

本文整理汇总了Java中com.intellij.openapi.util.io.FileUtil.sanitizeFileName方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtil.sanitizeFileName方法的具体用法?Java FileUtil.sanitizeFileName怎么用?Java FileUtil.sanitizeFileName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.util.io.FileUtil的用法示例。


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

示例1: CreateCourseArchivePanel

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
public CreateCourseArchivePanel(@NotNull final Project project, CreateCourseArchiveDialog dlg, String name) {
  setLayout(new BorderLayout());
  add(myPanel, BorderLayout.CENTER);
  myErrorIcon.setIcon(AllIcons.Actions.Lightning);
  setState(false);
  myDlg = dlg;
  String sanitizedName = FileUtil.sanitizeFileName(name);
  myNameField.setText(sanitizedName.startsWith("_") ? EduNames.COURSE : sanitizedName);
  myLocationField.setText(project.getBasePath());
  FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
  myLocationField.addBrowseFolderListener("Choose Location Folder", null, project, descriptor);
  myLocationField.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      String location = myLocationField.getText();
      File file = new File(location);
      if (!file.exists() || !file.isDirectory()) {
        myDlg.enableOKAction(false);
        setError("Invalid location");
      }
      myDlg.enableOKAction(true);
    }
  });
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:25,代码来源:CreateCourseArchivePanel.java

示例2: CreateCourseArchivePanel

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
public CreateCourseArchivePanel(@NotNull final Project project, CreateCourseArchiveDialog dlg, String name) {
  setLayout(new BorderLayout());
  add(myPanel, BorderLayout.CENTER);
  myErrorIcon.setIcon(AllIcons.Actions.Lightning);
  setState(false);
  myDlg = dlg;
  String sanitizedName = FileUtil.sanitizeFileName(name);
  myNameField.setText(sanitizedName.startsWith("_") ? EduNames.COURSE : sanitizedName);
  myLocationField.setText(project.getBasePath());
  FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor();
  myLocationField.addBrowseFolderListener("Choose location folder", null, project, descriptor);
  myLocationField.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      String location = myLocationField.getText();
      File file = new File(location);
      if (!file.exists() || !file.isDirectory()) {
        myDlg.enableOKAction(false);
        setError("Invalid location");
      }
      myDlg.enableOKAction(true);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:CreateCourseArchivePanel.java

示例3: getDefaultArtifactOutputPath

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@Nullable
public static String getDefaultArtifactOutputPath(@NotNull String artifactName, final @NotNull Project project) {
  final CompilerProjectExtension extension = CompilerProjectExtension.getInstance(project);
  if (extension == null) return null;
  String outputUrl = extension.getCompilerOutputUrl();
  if (outputUrl == null || outputUrl.length() == 0) {
    final VirtualFile baseDir = project.getBaseDir();
    if (baseDir == null) return null;
    outputUrl = baseDir.getUrl() + "/out";
  }
  return VfsUtilCore.urlToPath(outputUrl) + "/artifacts/" + FileUtil.sanitizeFileName(artifactName);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:ArtifactUtil.java

示例4: setUp

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
  super.setUp();

  if (shouldContainTempFiles()) {
    String testName =  FileUtil.sanitizeFileName(getTestName(true));
    if (StringUtil.isEmptyOrSpaces(testName)) testName = "";
    testName = new File(testName).getName(); // in case the test name contains file separators
    myTempDir = FileUtil.toSystemDependentName(ORIGINAL_TEMP_DIR + "/" + TEMP_DIR_MARKER + testName + "_"+ RNG.nextInt(1000));
    FileUtil.resetCanonicalTempPathCache(myTempDir);
  }
  ApplicationInfoImpl.setInPerformanceTest(isPerformanceTest());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:UsefulTestCase.java

示例5: suggestName

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
public String suggestName(String originalName) {
  String s = FileUtil.sanitizeFileName(originalName, false);
  if (!contains(s)) {
    myExistingNames.add(s);
    return s;
  }

  for (int postfix = myExistingNames.size(); ; postfix++){
    String s1 = s + postfix;
    if (!contains(s1)) {
      myExistingNames.add(s1);
      return s1;
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:UniqueFileNamesProvider.java

示例6: shortenAndSanitize

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@NotNull
private static String shortenAndSanitize(@NotNull String commitMessage) {
  @NonNls String defaultPath = FileUtil.sanitizeFileName(commitMessage);
  if (defaultPath.isEmpty()) {
    defaultPath = "unnamed";
  }
  if (defaultPath.length() > PatchNameChecker.MAX - 10) {
    defaultPath = defaultPath.substring(0, PatchNameChecker.MAX - 10);
  }
  return defaultPath;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:ShelveChangesManager.java

示例7: getArchiveFile

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
private File getArchiveFile(String postfix) {
  File tasksFolder = new File(PathManager.getConfigPath(), TASKS_FOLDER);
  if (!tasksFolder.exists()) {
    //noinspection ResultOfMethodCallIgnored
    tasksFolder.mkdirs();
  }
  String projectName = FileUtil.sanitizeFileName(myProject.getName());
  return new File(tasksFolder, projectName + postfix);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:WorkingContextManager.java

示例8: createCoverageFile

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@Nullable
@NonNls
protected String createCoverageFile() {
  if (myCoverageRunner == null) {
    return null;
  }

  @NonNls final String coverageRootPath = PathManager.getSystemPath() + File.separator + "coverage";
  final String path = coverageRootPath + File.separator + myProject.getName() + coverageFileNameSeparator()
                      + FileUtil.sanitizeFileName(myConfiguration.getName()) + ".coverage";

  new File(coverageRootPath).mkdirs();
  return path;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:CoverageEnabledConfiguration.java

示例9: nameToLocation

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@NotNull
private static String nameToLocation(@NotNull String courseName) {
  String name = FileUtil.sanitizeFileName(courseName);
  return FileUtil.findSequentNonexistentFile(new File(ProjectUtil.getBaseDir()), name, "").getAbsolutePath();
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:6,代码来源:EduCoursesPanel.java

示例10: convertName

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
public static String convertName(String s) {
  return FileUtil.sanitizeFileName(s, false);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:UniqueFileNamesProvider.java

示例11: getName

import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@Override
public String getName() {
  return name.getMethodName() == null ? super.getName() : FileUtil.sanitizeFileName(name.getMethodName());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:GradleImportingTestCase.java


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