本文整理汇总了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);
}
});
}
示例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);
}
});
}
示例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);
}
示例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());
}
示例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;
}
}
}
示例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;
}
示例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);
}
示例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;
}
示例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();
}
示例10: convertName
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
public static String convertName(String s) {
return FileUtil.sanitizeFileName(s, false);
}
示例11: getName
import com.intellij.openapi.util.io.FileUtil; //导入方法依赖的package包/类
@Override
public String getName() {
return name.getMethodName() == null ? super.getName() : FileUtil.sanitizeFileName(name.getMethodName());
}