
Java: Getting a substring from a string starting after a particular ...
I have a string: /abc/def/ghfj.doc I would like to extract ghfj.doc from this, i.e. the substring after the last /, or first / from right. Could someone please provide some help?
java - how the subString () function of string class works - Stack Overflow
“Substring creates a new object out of source string by taking a portion of original string”. Until Java 1.7, substring holds the reference of the original character array, which means even a sub-string of 5 …
Java substring: 'String index out of range' - Stack Overflow
Jun 5, 2009 · Java's substring method fails when you try and get a substring starting at an index which is longer than the string. An easy alternative is to use Apache Commons StringUtils.substring:
Java - removing first character of a string - Stack Overflow
Dec 22, 2010 · Use the substring() function with an argument of 1 to get the substring from position 1 (after the first character) to the end of the string (leaving the second argument out defaults to the full …
How to extract specific parts of a string JAVA - Stack Overflow
Feb 18, 2017 · In the example code above we use the String.substring () method to gather our sub-string from within the string. To get this sub-string we need to supply the String.substring () method …
How to remove the last character from a string? - Stack Overflow
Sep 16, 2011 · If one simply applies the currently accepted answer (using str.substring(0, str.length() - 1), one splices the surrogate pair, leading to unexpected results. One should also include a check …
What does String.substring exactly do in Java? - Stack Overflow
May 31, 2012 · I always thought if I do String s = "Hello World".substring(0, 5), then I just get a new string s = "Hello". This is also documented in the Java API doc: "Returns a new string that is a …
In Java, how do I check if a string contains a substring (ignoring case ...
In Java, how do I check if a string contains a substring (ignoring case)? [duplicate] Asked 15 years, 10 months ago Modified 4 years ago Viewed 1.3m times
Java - Strings and the substring method - Stack Overflow
Apr 19, 2013 · Strings in Java are immutable. Basically this means that, once you create a string object, you won't be able to modify/change the content of a string. As a result, if you perform any …
java - How do I get the first n characters of a string without checking ...
Oct 18, 2009 · How do I get up to the first n characters of a string in Java without doing a size check first (inline is acceptable) or risking an IndexOutOfBoundsException?