Hi I would like to know what should I put in order to split the string into parts using "\" as a delimiter?
The String returned by the server will be as shown below
String test ="\\ipAddress\FolderA\InnerFolderA\abc.mp4";
<< this one give me error ,thus i have to put in another "\",
String test ="\\ipAddress\\FolderA\\InnerFolderA\\abc.mp4";
String parts[] = test.split("\\");
String part0 = parts[0];
String part1 = parts[1];
String part2 = parts[2];
and when I run it, it gives me error:
Exception in thread "main" java.util.regex.PatternSyntaxException: Unexpected internal error near index 1.
Also when I tried replacing the String using this line of code to replace the "\" as in
String output = test.replaceAll("\\", ":");
it also give me error .
public static void main(String[] args) {
String test = "\\ipAddress\\FolderA\\InnerFolderA\\abc.mp4";
String output = test.replaceAll("\\\\", ":");
System.out.println(output);
String parts[] = test.split("\\\\");
String part0 = parts[0];
String part1 = parts[1];
String part2 = parts[2];
System.out.println(part0);
System.out.println(part1);
System.out.println(part2);
}
output
:ipAddress:FolderA:InnerFolderA:abc.mp4
ipAddress
FolderA
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加