-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathPathController.java
More file actions
41 lines (36 loc) · 964 Bytes
/
PathController.java
File metadata and controls
41 lines (36 loc) · 964 Bytes
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
package bookmark.utils;
import java.io.File;
public class PathController {
public static String conversion(String path) {
String ret = path;
String separatore = File.separator;
String sepAlfa = "/";
String sepBeta = "\\";
if (path.lastIndexOf(sepAlfa) != -1 || path.lastIndexOf(sepBeta) != -1) {
if (path.lastIndexOf(separatore) == -1) {
// devo switchare
if (separatore.equals(sepAlfa)) {
ret = path.replace(sepBeta, sepAlfa);
} else if (separatore.equals(sepBeta)) {
ret = path.replace(sepAlfa, sepBeta);
}
}
}
return ret;
}
public static boolean check(String path) {
boolean ret = false;
String sepCheck = "";
String sepAlfa = "/";
String sepBeta = "\\";
if (!File.separator.equals(sepAlfa)) {
sepCheck = sepAlfa;
} else if (!File.separator.equals(sepBeta)) {
sepCheck = sepBeta;
}
if (!sepCheck.equals("") && path.lastIndexOf(sepCheck) != -1) {
ret = true;
}
return ret;
}
}