N
Novice
Hi, I was just examining the SDK API and noticed this method in PrintStream:
private void write(char buf[]) {
try {
synchronized (this) {
ensureOpen();
textOut.write(buf);
textOut.flushBuffer();
charOut.flushBuffer();
if (autoFlush) {
for (int i = 0; i < buf.length; i++)
if (buf == '\n')
out.flush();
}
}
}
catch (InterruptedIOException x) {
Thread.currentThread().interrupt();
}
catch (IOException x) {
trouble = true;
}
}
I also noticed that there is no write method in BufferedWriter that takes a
char array as its only argument.
However, I did notice this method in BufferedWriter:
public void write(int c) throws IOException {
synchronized (lock) {
ensureOpen();
if (nextChar >= nChars)
flushBuffer();
cb[nextChar++] = (char) c;
}
}
Does Java just take the first element of the char array to accomodate the
int parameter of BufferedWriter's write method?
Thanks,
Novice
private void write(char buf[]) {
try {
synchronized (this) {
ensureOpen();
textOut.write(buf);
textOut.flushBuffer();
charOut.flushBuffer();
if (autoFlush) {
for (int i = 0; i < buf.length; i++)
if (buf == '\n')
out.flush();
}
}
}
catch (InterruptedIOException x) {
Thread.currentThread().interrupt();
}
catch (IOException x) {
trouble = true;
}
}
I also noticed that there is no write method in BufferedWriter that takes a
char array as its only argument.
However, I did notice this method in BufferedWriter:
public void write(int c) throws IOException {
synchronized (lock) {
ensureOpen();
if (nextChar >= nChars)
flushBuffer();
cb[nextChar++] = (char) c;
}
}
Does Java just take the first element of the char array to accomodate the
int parameter of BufferedWriter's write method?
Thanks,
Novice