本文整理匯總了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());
}