|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
Object
Buffer
public class Buffer
A string buffer implements a mutable sequence of characters.
A string buffer is like a String, but can be modified. At any
point in time it contains some particular sequence of characters, but
the length and content of the sequence can be changed through certain
method calls.
The elements in the buffer can be accessed with the operators
get and
set using brackets.
| Constructor Summary | |
|---|---|
Buffer()
Constructs a string buffer with no characters in it and an initial capacity of 16 characters. |
|
Buffer(int capacity)
Constructs a string buffer with no characters in it and an initial capacity specified by the capacity argument. |
|
| Method Summary | |
|---|---|
Buffer |
append(boolean b)
Appends the string representation of the boolean
argument to the string buffer. |
Buffer |
append(char c)
Appends the specified char
argument to this string buffer. |
Buffer |
append(int i)
Appends the string representation of the int
argument to this string buffer. |
Buffer |
append(long l)
Appends the string representation of the long
argument to this string buffer. |
Buffer |
append(Object obj)
Appends the string representation of the Object
argument to this string buffer. |
Buffer |
delete(int start,
int end)
Removes the characters in a substring of this Buffer. |
Buffer |
insert(int offset,
boolean b)
Inserts the string representation of the boolean
argument into this string buffer. |
Buffer |
insert(int offset,
char c)
Inserts the second char
argument into this string buffer. |
Buffer |
insert(int offset,
int i)
Inserts the string representation of the second int
argument into this string buffer. |
Buffer |
insert(int offset,
long l)
Inserts the string representation of the long
argument into this string buffer. |
Buffer |
insert(int offset,
Object obj)
Inserts the string representation of the Object
argument into this string buffer. |
int |
length()
Returns the length (character count) of this string buffer. |
char |
operator_get(int index)
The specified character of the sequence currently represented by the string buffer, as indicated by the index argument,
is returned. |
char |
operator_set(int index,
char ch)
The character at the specified index of this string buffer is set to ch. |
void |
setLength(int newLength)
Sets the length of this String buffer. |
| Methods inherited from class Object |
|---|
toString, equals, hashCode |
| Methods inherited from |
|---|
equals, getClass, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Buffer()
public Buffer(int capacity)
capacity argument.
capacity - the initial capacity.| Method Detail |
|---|
public Buffer append(boolean b)
boolean
argument to the string buffer.
b - a boolean.
Buffer.public Buffer append(int i)
int
argument to this string buffer.
i - an int.
Buffer object.public Buffer append(char c)
char
argument to this string buffer.
c - an char.
Buffer object.public Buffer append(long l)
long
argument to this string buffer.
l - a long.
Buffer object.public Buffer append(Object obj)
Object
argument to this string buffer.
obj - an Object.
Buffer object.
public Buffer insert(int offset,
boolean b)
boolean
argument into this string buffer.
The offset argument must be greater than or equal to
0, and less than or equal to the length of this
string buffer.
offset - the offset.b - a boolean.
Buffer object.
public Buffer insert(int offset,
int i)
int
argument into this string buffer.
The offset argument must be greater than or equal to
0, and less than or equal to the length of this
string buffer.
offset - the offset.i - an int.
Buffer object.
public Buffer insert(int offset,
char c)
char
argument into this string buffer.
The offset argument must be greater than or equal to
0, and less than or equal to the length of this
string buffer.
offset - the offset.c - an char.
Buffer object.
public Buffer insert(int offset,
long l)
long
argument into this string buffer.
The offset argument must be greater than or equal to
0, and less than or equal to the length of this
string buffer.
offset - the offset.l - a long.
Buffer object.
public Buffer insert(int offset,
Object obj)
Object
argument into this string buffer.
The offset argument must be greater than or equal to
0, and less than or equal to the length of this
string buffer.
offset - the offset.obj - an Object.
Buffer object.public char operator_get(int index)
index argument,
is returned. The first character of a string buffer is at index
0, the next at index 1, and so on, for
array indexing.
The index argument must be greater than or equal to
0, and less than the length of this string buffer.
index - the index of the desired character.
length(),
get
public char operator_set(int index,
char ch)
ch. The string buffer is altered to represent a new
character sequence that is identical to the old character sequence,
except that it contains the character ch at position
index.
The offset argument must be greater than or equal to
0, and less than the length of this string buffer.
index - the index of the character to modify.ch - the new character.length(),
set
public Buffer delete(int start,
int end)
Buffer.
The substring begins at the specified start and extends to
the character at index end - 1 or to the end of the
Buffer if no such character exists. If
start is equal to end, no changes are made.
start - The beginning index, inclusive.end - The ending index, exclusive.
public int length()
public void setLength(int newLength)
newLength, the character at
index k in the new character sequence is the same as the
character at index k in the old sequence if k is less
than the length of the old character sequence; otherwise, it is the
null character ' '.
In other words, if the newLength argument is less than
the current length of the string buffer, the string buffer is
truncated to contain exactly the number of characters given by the
newLength argument.
If the newLength argument is greater than or equal
to the current length, sufficient null characters
('\u0000') are appended to the string buffer so that
length becomes the newLength argument.
The newLength argument must be greater than or equal
to 0.
newLength - the new length of the buffer.length()
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||