I want to parse a String which has UUID in the below format
\"<urn:uuid:4324e9d5-8d1f-442c-96a4-6146640da7ce>\"
I have tried
If this format don't be changed. I think more fast way is use String.substring() method. Example:
String val = "<urn:uuid:4324e9d5-8d1f-442c-96a4-6146640da7ce>";
String sUuid = val.substring(13, 49);
UUID uuid = UUID.fromString(sUuid);
Inside class String used char array for store data, in package java.lang.String:
public final class String
implements java.io.Serializable, Comparable, CharSequence {
...
113: /** The value is used for character storage. */
114: private final char value[];
...
}
Method 'String substring(int beginIndex, int endIndex)' make the copy of array elements, from start to end index, and create new String on basis new array. Copying of array it is a very fast operation.