blob: c724760c280a04c34d70cdedc8ab3e445b96c5a1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
package rba.tool.core.ui;
import java.nio.file.Files;
import java.nio.file.Paths;
import org.apache.commons.lang3.StringUtils;
public class CommonValueValidator {
public static boolean isExistFilePath(String folderPath, String fileName) {
if (StringUtils.isEmpty(folderPath) || StringUtils.isEmpty(fileName))
return false;
return Files.exists(Paths.get(folderPath, fileName));
}
public static boolean isExistFilePath(String filePath) {
if (StringUtils.isEmpty(filePath))
return false;
return Files.exists(Paths.get(filePath));
}
public static boolean isValidFileName(String target) {
if (StringUtils.isEmpty(target)) {
return false;
}
if (target.length() > 250) {
return false;
}
if (target.contains("¥") || target.contains("/") || target.contains(":") || target.contains("*") || target.contains("?") || target.contains("\"") || target.contains("|")
|| target.contains("<") || target.contains(">")) {
return false;
}
return true;
}
public static boolean isValidFolderName(String target) {
if (StringUtils.isEmpty(target)) {
return false;
}
if (target.length() > 250) {
return false;
}
if (target.contains("¥") || target.contains("/") || target.contains(":") || target.contains("*") || target.contains("?") || target.contains("\"") || target.contains("|")
|| target.contains("<") || target.contains(">") || target.contains(".") || target.contains(",")) {
return false;
}
return true;
}
}
|