當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。