本文整理了Java中java.io.Reader.skip
方法的一些代码示例,展示了Reader.skip
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Reader.skip
方法的具体详情如下:
包路径:java.io.Reader
类名称:Reader
方法名:skip
[英]Skips charCount characters in this reader. Subsequent calls of read methods will not return these characters unless reset is used. This method may perform multiple reads to read charCount characters.
[中]跳过此读取器中的字符数。除非使用重置,否则读取方法的后续调用将不会返回这些字符。此方法可以执行多次读取以读取字符数字符。
代码示例来源:origin: google/guava
private long countBySkipping(Reader reader) throws IOException {
long count = 0;
long read;
while ((read = reader.skip(Long.MAX_VALUE)) != 0) {
count += read;
}
return count;
}
代码示例来源:origin: prestodb/presto
private long countBySkipping(Reader reader) throws IOException {
long count = 0;
long read;
while ((read = reader.skip(Long.MAX_VALUE)) != 0) {
count += read;
}
return count;
}
代码示例来源:origin: google/j2objc
private long countBySkipping(Reader reader) throws IOException {
long count = 0;
long read;
while ((read = reader.skip(Long.MAX_VALUE)) != 0) {
count += read;
}
return count;
}
代码示例来源:origin: com.h2database/h2
@Override
public long skip(long n) throws IOException {
if (n > limit) {
n = (int) limit;
}
n = r.skip(n);
limit -= n;
return n;
}
代码示例来源:origin: wildfly/wildfly
private long countBySkipping(Reader reader) throws IOException {
long count = 0;
long read;
while ((read = reader.skip(Long.MAX_VALUE)) != 0) {
count += read;
}
return count;
}
代码示例来源:origin: igniterealtime/Smack
@Override
public long skip(long n) throws IOException {
return wrappedReader.skip(n);
}
代码示例来源:origin: google/guava
/**
* Discards {@code n} characters of data from the reader. This method will block until the full
* amount has been skipped. Does not close the reader.
*
* @param reader the reader to read from
* @param n the number of characters to skip
* @throws EOFException if this stream reaches the end before skipping all the characters
* @throws IOException if an I/O error occurs
*/
public static void skipFully(Reader reader, long n) throws IOException {
checkNotNull(reader);
while (n > 0) {
long amt = reader.skip(n);
if (amt == 0) {
throw new EOFException();
}
n -= amt;
}
}
代码示例来源:origin: org.apache.ant/ant
public long skip(long i) throws java.io.IOException {
return in.skip(i);
}
代码示例来源:origin: org.apache.commons/commons-io
/** @see java.io.Reader#skip(long) */
public long skip(long ln) throws IOException {
return in.skip(ln);
}
代码示例来源:origin: google/guava
@Override
public long skip(long n) throws IOException {
Preconditions.checkArgument(n >= 0, "n is negative");
if (n > 0) {
while (current != null) {
long result = current.skip(n);
if (result > 0) {
return result;
}
advance();
}
}
return 0;
}
代码示例来源:origin: google/j2objc
/**
* Discards {@code n} characters of data from the reader. This method will block until the full
* amount has been skipped. Does not close the reader.
*
* @param reader the reader to read from
* @param n the number of characters to skip
* @throws EOFException if this stream reaches the end before skipping all the characters
* @throws IOException if an I/O error occurs
*/
public static void skipFully(Reader reader, long n) throws IOException {
checkNotNull(reader);
while (n > 0) {
long amt = reader.skip(n);
if (amt == 0) {
throw new EOFException();
}
n -= amt;
}
}
代码示例来源:origin: commons-io/commons-io
/**
* Invokes the delegate's <code>skip(long)</code> method.
* @param ln the number of bytes to skip
* @return the number of bytes to skipped or EOF if the end of stream
* @throws IOException if an I/O error occurs
*/
@Override
public long skip(final long ln) throws IOException {
try {
return in.skip(ln);
} catch (final IOException e) {
handleIOException(e);
return 0;
}
}
代码示例来源:origin: google/j2objc
@Override
public long skip(long n) throws IOException {
Preconditions.checkArgument(n >= 0, "n is negative");
if (n > 0) {
while (current != null) {
long result = current.skip(n);
if (result > 0) {
return result;
}
advance();
}
}
return 0;
}
代码示例来源:origin: prestodb/presto
/**
* Discards {@code n} characters of data from the reader. This method will block until the full
* amount has been skipped. Does not close the reader.
*
* @param reader the reader to read from
* @param n the number of characters to skip
* @throws EOFException if this stream reaches the end before skipping all the characters
* @throws IOException if an I/O error occurs
*/
public static void skipFully(Reader reader, long n) throws IOException {
checkNotNull(reader);
while (n > 0) {
long amt = reader.skip(n);
if (amt == 0) {
throw new EOFException();
}
n -= amt;
}
}
代码示例来源:origin: wildfly/wildfly
@Override
public long skip(long n) throws IOException {
Preconditions.checkArgument(n >= 0, "n is negative");
if (n > 0) {
while (current != null) {
long result = current.skip(n);
if (result > 0) {
return result;
}
advance();
}
}
return 0;
}
代码示例来源:origin: prestodb/presto
@Override
public long skip(long n) throws IOException {
Preconditions.checkArgument(n >= 0, "n is negative");
if (n > 0) {
while (current != null) {
long result = current.skip(n);
if (result > 0) {
return result;
}
advance();
}
}
return 0;
}
代码示例来源:origin: neo4j/neo4j
@Override
public long skip( long n ) throws IOException
{
adversary.injectFailure( IllegalArgumentException.class, IOException.class );
return reader.skip( n );
}
代码示例来源:origin: commons-io/commons-io
@Test
public void testSkip() throws IOException {
final Reader reader = new CharSequenceReader("FooBar");
assertEquals(3, reader.skip(3));
checkRead(reader, "Bar");
assertEquals(-1, reader.skip(3));
reader.reset();
assertEquals(2, reader.skip(2));
assertEquals(4, reader.skip(10));
assertEquals(-1, reader.skip(1));
reader.close();
assertEquals(6, reader.skip(20));
assertEquals(-1, reader.read());
}
代码示例来源:origin: google/guava
public void testSkipZero() throws Exception {
CharSource source = newCharSource("a");
Iterable<CharSource> list = ImmutableList.of(source, source);
Reader joinedReader = CharSource.concat(list).openStream();
assertEquals(0, joinedReader.skip(0));
assertEquals('a', joinedReader.read());
}
}
代码示例来源:origin: commons-io/commons-io
@Test
public void testSkip() throws Exception {
final Reader reader = new TestNullReader(10, true, false);
assertEquals("Read 1", 0, reader.read());
assertEquals("Read 2", 1, reader.read());
assertEquals("Skip 1", 5, reader.skip(5));
assertEquals("Read 3", 7, reader.read());
assertEquals("Skip 2", 2, reader.skip(5)); // only 2 left to skip
assertEquals("Skip 3 (EOF)", -1, reader.skip(5)); // End of file
try {
reader.skip(5); //
fail("Expected IOException for skipping after end of file");
} catch (final IOException e) {
assertEquals("Skip after EOF IOException message",
"Skip after end of file",
e.getMessage());
}
reader.close();
}
内容来源于网络,如有侵权,请联系作者删除!