sb = | new StringBuffer() |
Creates empty StringBuffer |
sb = | new StringBuffer(n) |
Creates empty StringBuffer with capacity n. |
sb = | new StringBuffer(s) |
Creates StringBuffer with value initialized to String s. |
i = | sb.length() |
Length of the current contents of sb. |
| sb.append(x) |
Appends x (char, int, String, ...) to end of sb. |
| sb.insert(offset, x) |
Inserts x (char, int, String, ...) at position offset. |
| sb.setCharAt(index, c) |
Replaces char at index with c |
| sb.delete(beg, end) |
Deletes chars at index beg thru end. |
| sb.reverse() |
Reverses the contents. |
s1 = | sb.replace(beg, end, s) |
Replaces characters beg thru end with s. |
c = | sb.charAt(i) |
char at position i in sb. |
s = | sb.substring(i) |
substring from index i to the end of sb. |
s = | sb.substring(i, j) |
substring from index i to BEFORE index j of sb. |
s = | sb.toString() |
Returns a String for the contents of sb. |
i = | sb.indexOf(s) |
index of the first occurrence of String s in s. |
i = | sb.indexOf(s, i) |
index of String s at or after position i in sb. |
i = | sb.lastIndexOf(s) |
index of last occurrence of s in sb. |
i = | sb.lastIndexOf(s, i) |
index of last occurrence of s on or before i in sb. |
b = | sb.equals(sb2) |
true if the two StringBuffers contain equal values |
StringTokenizer is used to break a string into "words" (tokens).
st = new StringTokenizer(s); |
Creates a StringTokenizer on String s |
st = new StringTokenizer(s, delims); |
As above with delimiter characters in String delims |
st = new StringTokenizer(s, delims, true); |
As above, but also returns delimiters as tokens. |
int st.countTokens() |
Returns number of tokens. Must scan everything. |
boolean st.hasMoreTokens() |
true if nextToken will return something. |
String st.nextToken() |
Returns next token. |
java.io.BufferedReader and java.io.BufferedWriter are
used to read/write Strings from/to text files.