本文整理了Java中java.io.BufferedReader.fill()
方法的一些代码示例,展示了BufferedReader.fill()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BufferedReader.fill()
方法的具体详情如下:
包路径:java.io.BufferedReader
类名称:BufferedReader
方法名:fill
[英]Fills the input buffer, taking the mark into account if it is valid.
[中]填充输入缓冲区,如果标记有效,则将其考虑在内。
代码示例来源:origin: dragome/dragome-sdk
public int read (char[] b, int offset, int length) throws IOException {
int count = 0;
if (position >= limit && length < buffer.length) {
fill();
}
if (position < limit) {
int remaining = limit - position;
if (remaining > length) {
remaining = length;
}
System.arraycopy(buffer, position, b, offset, remaining);
count += remaining;
position += remaining;
offset += remaining;
length -= remaining;
}
if (length > 0) {
int c = in.read(b, offset, length);
if (c == -1) {
if (count == 0) {
count = -1;
}
} else {
count += c;
}
}
return count;
}
代码示例来源:origin: jtulach/bck2brwsr
return in.read(cbuf, off, len);
fill();
nextChar++;
if (nextChar >= nChars)
fill();
if (nextChar >= nChars)
return -1;
代码示例来源:origin: org.apidesign.bck2brwsr/emul
return in.read(cbuf, off, len);
fill();
nextChar++;
if (nextChar >= nChars)
fill();
if (nextChar >= nChars)
return -1;
代码示例来源:origin: stackoverflow.com
Exception in thread "main" java.lang.NullPointerException
at java.io.FilterInputStream.read(FilterInputStream.java:133)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
at java.io.InputStreamReader.read(InputStreamReader.java:184)
at java.io.BufferedReader.fill(BufferedReader.java:161)
at java.io.BufferedReader.readLine(BufferedReader.java:324)
at java.io.BufferedReader.readLine(BufferedReader.java:389)
代码示例来源:origin: thothbot/parallax
public int read (char[] b, int offset, int length) throws IOException {
int count = 0;
if (position >= limit && length < buffer.length) {
fill();
}
if (position < limit) {
int remaining = limit - position;
if (remaining > length) {
remaining = length;
}
System.arraycopy(buffer, position, b, offset, remaining);
count += remaining;
position += remaining;
offset += remaining;
length -= remaining;
}
if (length > 0) {
int c = in.read(b, offset, length);
if (c == -1) {
if (count == 0) {
count = -1;
}
} else {
count += c;
}
}
return count;
}
代码示例来源:origin: thothbot/parallax
while (true) {
if (position >= limit) {
fill();
fill();
if (buffer[position] == '\n') {
position += 1;
代码示例来源:origin: dragome/dragome-sdk
while (true) {
if (position >= limit) {
fill();
fill();
if (buffer[position] == '\n') {
position += 1;
代码示例来源:origin: org.apidesign.bck2brwsr/emul
/**
* Reads a single character.
*
* @return The character read, as an integer in the range
* 0 to 65535 (<tt>0x00-0xffff</tt>), or -1 if the
* end of the stream has been reached
* @exception IOException If an I/O error occurs
*/
public int read() throws IOException {
synchronized (lock) {
ensureOpen();
for (;;) {
if (nextChar >= nChars) {
fill();
if (nextChar >= nChars)
return -1;
}
if (skipLF) {
skipLF = false;
if (cb[nextChar] == '\n') {
nextChar++;
continue;
}
}
return cb[nextChar++];
}
}
}
代码示例来源:origin: jtulach/bck2brwsr
/**
* Tells whether this stream is ready to be read. A buffered character
* stream is ready if the buffer is not empty, or if the underlying
* character stream is ready.
*
* @exception IOException If an I/O error occurs
*/
public boolean ready() throws IOException {
synchronized (lock) {
ensureOpen();
/*
* If newline needs to be skipped and the next char to be read
* is a newline character, then just skip it right away.
*/
if (skipLF) {
/* Note that in.ready() will return true if and only if the next
* read on the stream will not block.
*/
if (nextChar >= nChars && in.ready()) {
fill();
}
if (nextChar < nChars) {
if (cb[nextChar] == '\n')
nextChar++;
skipLF = false;
}
}
return (nextChar < nChars) || in.ready();
}
}
代码示例来源:origin: jtulach/bck2brwsr
/**
* Reads a single character.
*
* @return The character read, as an integer in the range
* 0 to 65535 (<tt>0x00-0xffff</tt>), or -1 if the
* end of the stream has been reached
* @exception IOException If an I/O error occurs
*/
public int read() throws IOException {
synchronized (lock) {
ensureOpen();
for (;;) {
if (nextChar >= nChars) {
fill();
if (nextChar >= nChars)
return -1;
}
if (skipLF) {
skipLF = false;
if (cb[nextChar] == '\n') {
nextChar++;
continue;
}
}
return cb[nextChar++];
}
}
}
代码示例来源:origin: org.apidesign.bck2brwsr/emul
/**
* Tells whether this stream is ready to be read. A buffered character
* stream is ready if the buffer is not empty, or if the underlying
* character stream is ready.
*
* @exception IOException If an I/O error occurs
*/
public boolean ready() throws IOException {
synchronized (lock) {
ensureOpen();
/*
* If newline needs to be skipped and the next char to be read
* is a newline character, then just skip it right away.
*/
if (skipLF) {
/* Note that in.ready() will return true if and only if the next
* read on the stream will not block.
*/
if (nextChar >= nChars && in.ready()) {
fill();
}
if (nextChar < nChars) {
if (cb[nextChar] == '\n')
nextChar++;
skipLF = false;
}
}
return (nextChar < nChars) || in.ready();
}
}
代码示例来源:origin: org.apidesign.bck2brwsr/emul
while (r > 0) {
if (nextChar >= nChars)
fill();
if (nextChar >= nChars) /* EOF */
break;
代码示例来源:origin: jtulach/bck2brwsr
while (r > 0) {
if (nextChar >= nChars)
fill();
if (nextChar >= nChars) /* EOF */
break;
代码示例来源:origin: stackoverflow.com
"main" #1 prio=5 os_prio=31 tid=0x00007fef4d803000 nid=0xf07
waiting for monitor entry [0x000000010b7a3000]
java.lang.Thread.State: BLOCKED (on object monitor)
at java.io.BufferedReader.close(BufferedReader.java:522)
- waiting to lock <0x000000076ac47f78> (a java.io.InputStreamReader)
at ReaderService.stop(ReaderService.java:19)
at ReaderService.main(ReaderService.java:34)
"Thread-0" #10 prio=5 os_prio=31 tid=0x00007fef4c873800 nid=0x5503 runnable [0x000000012b497000]
java.lang.Thread.State: RUNNABLE
at java.io.FileInputStream.readBytes(Native Method)
at java.io.FileInputStream.read(FileInputStream.java:255)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:284)
at java.io.BufferedInputStream.read(BufferedInputStream.java:345)
- locked <0x000000076ab1bf10> (a java.io.BufferedInputStream)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178)
- locked <0x000000076ac47f78> (a java.io.InputStreamReader)
at java.io.InputStreamReader.read(InputStreamReader.java:184)
at java.io.BufferedReader.fill(BufferedReader.java:161)
at java.io.BufferedReader.readLine(BufferedReader.java:324)
- locked <0x000000076ac47f78> (a java.io.InputStreamReader)
at java.io.BufferedReader.readLine(BufferedReader.java:389)
at ReaderService.start(ReaderService.java:10)
at ReaderService$1.run(ReaderService.java:29)
at java.lang.Thread.run(Thread.java:745)
代码示例来源:origin: stackoverflow.com
> jps
83518 Test
> jstack 83518
2015-12-24 21:25:17
Full thread dump Java HotSpot(TM) 64-Bit Server VM (24.65-b04 mixed mode):
...
"main" prio=5 tid=0x00007fbba2001000 nid=0x1903 runnable [0x000000010a560000]
java.lang.Thread.State: RUNNABLE
at java.io.FileInputStream.readBytes(Native Method)
at java.io.FileInputStream.read(FileInputStream.java:272)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:273)
at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
- locked <0x00000007aaa9a5f0> (a java.io.BufferedInputStream)
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:283)
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:325)
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:177)
- locked <0x00000007aab2ad88> (a java.io.InputStreamReader)
at java.io.InputStreamReader.read(InputStreamReader.java:184)
at java.io.BufferedReader.fill(BufferedReader.java:154)
at java.io.BufferedReader.readLine(BufferedReader.java:317)
- locked <0x00000007aab2ad88> (a java.io.InputStreamReader)
at java.io.BufferedReader.readLine(BufferedReader.java:382)
at Test.main(Test.java:22)
...
代码示例来源:origin: jtulach/bck2brwsr
fill();
if (nextChar >= nChars) { /* EOF */
if (s != null && s.length() > 0)
代码示例来源:origin: org.apidesign.bck2brwsr/emul
fill();
if (nextChar >= nChars) { /* EOF */
if (s != null && s.length() > 0)
代码示例来源:origin: stackoverflow.com
fill();
if (nextChar >= nChars) { /* EOF */
if (s != null && s.length() > 0)
内容来源于网络,如有侵权,请联系作者删除!