java.io.BufferedReader.skip()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(301)

本文整理了Java中java.io.BufferedReader.skip()方法的一些代码示例,展示了BufferedReader.skip()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。BufferedReader.skip()方法的具体详情如下:
包路径:java.io.BufferedReader
类名称:BufferedReader
方法名:skip

BufferedReader.skip介绍

[英]Skips at most charCount chars in this stream. Subsequent calls to read will not return these chars unless reset is used.

Skipping characters may invalidate a mark if markLimitis surpassed.
[中]在此流中最多跳过个charCount字符。除非使用reset,否则后续的read调用将不会返回这些字符。
如果超过标记限制,跳过字符可能会使标记无效。

代码示例

代码示例来源:origin: apache/storm

private TextFileReader(FileSystem fs, Path file, Map<String, Object> conf, TextFileReader.Offset startOffset)
  throws IOException {
  super(fs, file);
  offset = startOffset;
  FSDataInputStream in = fs.open(file);
  String charSet = (conf == null || !conf.containsKey(CHARSET)) ? "UTF-8" : conf.get(CHARSET).toString();
  int buffSz =
    (conf == null || !conf.containsKey(BUFFER_SIZE)) ? DEFAULT_BUFF_SIZE : Integer.parseInt(conf.get(BUFFER_SIZE).toString());
  reader = new BufferedReader(new InputStreamReader(in, charSet), buffSz);
  if (offset.charOffset > 0) {
    reader.skip(offset.charOffset);
  }
}

代码示例来源:origin: pmd/pmd

private void tryToReplaceInFile(final RegionByOffset regionByOffset, final String textToReplace) throws IOException {
  writeUntilOffsetReached(regionByOffset.getOffset());
  reader.skip(regionByOffset.getLength());
  currentPosition = regionByOffset.getOffsetAfterEnding();
  writer.write(textToReplace);
}

代码示例来源:origin: pmd/pmd

private void tryToDeleteFromFile(final RegionByOffset regionByOffset) throws IOException {
  writeUntilOffsetReached(regionByOffset.getOffset());
  reader.skip(regionByOffset.getLength());
  currentPosition = regionByOffset.getOffsetAfterEnding();
}

代码示例来源:origin: org.jsoup/jsoup

BufferedReader reader = new BufferedReader(new InputStreamReader(input, charsetName), bufferSize);
if (bomCharset != null && bomCharset.offset) // creating the buffered reader ignores the input pos, so must skip here
  reader.skip(1);
try {
  doc = parser.parseInput(reader, baseUri);

代码示例来源:origin: ahmetaa/zemberek-nlp

/**
 * Returns an Iterator that loads [blocksize] lines in each iteration. It starts loading from
 * [charIndex] value of the content.
 */
Iterator<TextChunk> iteratorFromCharIndex(long charIndex) {
 try {
  BufferedReader reader = Files.newBufferedReader(path, charset);
  long k = reader.skip(charIndex);
  if (k != charIndex) {
   throw new IllegalStateException("Cannot skip " + charIndex + " skip returned " + k);
  }
  if (charIndex != 0) { // skip first line
   reader.readLine();
  }
  return new TextIterator(reader);
 } catch (IOException e) {
  e.printStackTrace();
  throw new RuntimeException(e);
 }
}

代码示例来源:origin: com.github.akurilov/java-commons

/**
 * Skips characters instead of lines
 */
@Override
public long skip(final long count)
throws IOException {
  return reader.skip(count);
}

代码示例来源:origin: com.atlassian.jira/jira-core

public long skip(final long n) throws IOException
{
  return delegate.skip(n);
}

代码示例来源:origin: org.jwall/org.jwall.web.audit

@Override
public void skip(Long bytes) {
  try {
    Long skipped = reader.skip( bytes );
    bytesRead += skipped;
  } catch (Exception e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: stackoverflow.com

BufferedReader reader = new BufferedReader(new InputStreamReader(fileInputStream));
// read what you want here
reader.skip(20);
// read the rest of the file after skipping

代码示例来源:origin: org.wso2.carbon.touchpoint/org.wso2.carbon.extensions.touchpoint

private void readOffStream(InputStream inputStream) {
    try (BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, Charset.defaultCharset()))) {
      while (reader.skip(Long.MAX_VALUE) == Long.MAX_VALUE) {
        // do nothing
      }
    } catch (IOException e) {
      // ignore
    }
  }
}

代码示例来源:origin: stackoverflow.com

InputStream is = new FileInputStream(filePath);
BufferedReader reader = new BufferedReader(new InputStreamReader(is,"UTF-8"));
reader.skip(n); // chars to skip
// .. and here you can start reading

代码示例来源:origin: org.apache.storm/storm-hdfs

private TextFileReader(FileSystem fs, Path file, Map conf, TextFileReader.Offset startOffset)
    throws IOException {
 super(fs, file);
 offset = startOffset;
 FSDataInputStream in = fs.open(file);
 String charSet = (conf==null || !conf.containsKey(CHARSET) ) ? "UTF-8" : conf.get(CHARSET).toString();
 int buffSz = (conf==null || !conf.containsKey(BUFFER_SIZE) ) ? DEFAULT_BUFF_SIZE : Integer.parseInt( conf.get(BUFFER_SIZE).toString() );
 reader = new BufferedReader(new InputStreamReader(in, charSet), buffSz);
 if(offset.charOffset >0) {
  reader.skip(offset.charOffset);
 }
}

代码示例来源:origin: com.caucho/resin

@Override
public long skip(long n) throws IOException
{
 BufferedReader reader = _bufferedReader;
 
 if (reader != null)
  return reader.skip(n);
 
 long count = 0;
 for (; count < n && _rs.readChar() >= 0; count++) {
 }
 return count;
}

代码示例来源:origin: Esri/spatial-framework-for-hadoop

private void commonInit(Path filePath, Configuration conf) throws IOException {
  readerPosition = start;
  FileSystem fs = filePath.getFileSystem(conf);
  inputReader = new BufferedReader(new InputStreamReader(fs.open(filePath)));
  if (start != 0) {
    // split starts inside the json
    inputReader.skip(start);
    moveToRecordStart();
  }
}

代码示例来源:origin: baratine/baratine

@Override
public long skip(long n) throws IOException
{
 BufferedReader reader = _bufferedReader;
 
 if (reader != null)
  return reader.skip(n);
 
 long count = 0;
 for (; count < n && _rs.readChar() >= 0; count++) {
 }
 return count;
}

代码示例来源:origin: biojava/biojava

/**
 *  Load the sequence
 * @return
 */
private boolean init() throws IOException, CompoundNotFoundException {
  BufferedReader br = new BufferedReader(new FileReader(file));
  br.skip(sequenceStartIndex);
  String sequence = sequenceParser.getSequence(br, sequenceLength);
  setContents(sequence);
  br.close(); // close file to prevent too many being open
  return true;
}

代码示例来源:origin: org.biojava/biojava-core

/**
 *  Load the sequence
 * @return
 */
private boolean init() throws IOException, CompoundNotFoundException {
  BufferedReader br = new BufferedReader(new FileReader(file));
  br.skip(sequenceStartIndex);
  String sequence = sequenceParser.getSequence(br, sequenceLength);
  setContents(sequence);
  br.close(); // close file to prevent too many being open
  return true;
}

代码示例来源:origin: apache/jackrabbit

private Tail(File file, String grep) throws IOException {
  this.grep = grep;
  this.reader = new BufferedReader(new InputStreamReader(
      new FileInputStream(file)));
  while (reader.skip(Integer.MAX_VALUE) > 0) {
    // skip more, until end of file
  }
}

代码示例来源:origin: net.sourceforge.pmd/pmd-core

private void tryToReplaceInFile(final RegionByOffset regionByOffset, final String textToReplace) throws IOException {
  writeUntilOffsetReached(regionByOffset.getOffset());
  reader.skip(regionByOffset.getLength());
  currentPosition = regionByOffset.getOffsetAfterEnding();
  writer.write(textToReplace);
}

代码示例来源:origin: net.sourceforge.pmd/pmd-core

private void tryToDeleteFromFile(final RegionByOffset regionByOffset) throws IOException {
  writeUntilOffsetReached(regionByOffset.getOffset());
  reader.skip(regionByOffset.getLength());
  currentPosition = regionByOffset.getOffsetAfterEnding();
}

相关文章