|
Spec-Zone .ru
спецификации, руководства, описания, API
|
File f1 = new File("foo");
File f2 = new File("bar");
f1.renameTo(f2);
will rename the file named "foo" (if it exists) to
"bar". It will not change the value of the File
object referred to by f1; in particular, the expression
f1.getPath() will still evaluate to "foo".
int n = in.available();
byte buf = new byte[n];
in.read(buf);
is not guaranteed to read all of the remaining bytes from the given
input stream. Similarly, the ready method of
Reader and
its subclasses may return false even if the stream is
ready to be read.
for (int off = 0; off < size;) {
int r = in.read(buf, off, buf.length - off);
if (r == -1) break;
off += r;
}
Alternatively, a BufferedInputStream
may be used. Similar remarks apply to the read(char[])
and read(char[], int, int)
methods of Reader and its
subclasses.