org.topoweb.util
Class StringUtil
java.lang.Object
|
+--org.topoweb.util.StringUtil
- public class StringUtil
- extends java.lang.Object
Procedures for manipulating strings.
Method Summary |
static java.lang.StringBuffer |
appendSubstring(java.lang.StringBuffer buffer,
java.lang.String string,
int start,
int end)
Appends the specified substring into the given buffer. |
static int |
nthIndexOf(char c,
java.lang.String string,
int n)
Finds and returns the index of the nth occurance of the
specified character in the given string. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
StringUtil
public StringUtil()
appendSubstring
public static java.lang.StringBuffer appendSubstring(java.lang.StringBuffer buffer,
java.lang.String string,
int start,
int end)
- Appends the specified substring into the given buffer. If the
buffer has enough capacity, no intermediate objects are allocated.
If the passed in substring indices are out of bounds, an
IndexOutOfBoundsException
is thrown in a non-fail-safe
manner (the state of the buffer
may have changed).
- Parameters:
buffer
- the buffer
appendedstring
- the string copied fromstart
- the inclusive starting index of the substring in
string
end
- the exclusive ending index of the substring in
string
- Returns:
- the
buffer
passed in
nthIndexOf
public static int nthIndexOf(char c,
java.lang.String string,
int n)
- Finds and returns the index of the nth occurance of the
specified character in the given string. The behavior is undefined if
n <= 0.
- Parameters:
c
- the character searched forstring
- the string searched inn
- the nth occurance of c
- Returns:
- the index of the
n
th
occurance of c
in the given
string
; or -1, if c
does not
occur n
times
Copyright (C) 2002 Babak Farhang
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.