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

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

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

ByteArrayInputStream.skip介绍

[英]Skips byteCount bytes in this InputStream. Subsequent calls to read will not return these bytes unless reset is used. This implementation skips byteCount number of bytes in the target stream. It does nothing and returns 0 if byteCount is negative.
[中]跳过此输入流中的字节计数字节。除非使用reset,否则后续的read调用将不会返回这些字节。此实现跳过目标流中字节数的字节计数。如果字节数为负数,则不执行任何操作并返回0。

代码示例

代码示例来源:origin: CarGuo/GSYVideoPlayer

@Override
public void open(long offset) throws ProxyCacheException {
  arrayInputStream = new ByteArrayInputStream(data);
  arrayInputStream.skip(offset);
}

代码示例来源:origin: com.h2database/h2

@Override
public long skip(long n) {
  n = Math.min(length - pos, n);
  if (n == 0) {
    return 0;
  }
  if (buffer != null) {
    long s = buffer.skip(n);
    if (s > 0) {
      n = s;
    } else {
      buffer = null;
      skip += n;
    }
  } else {
    skip += n;
  }
  pos += n;
  return n;
}

代码示例来源:origin: lealone/Lealone

@Override
public long skip(long n) {
  n = Math.min(length - pos, n);
  if (n == 0) {
    return 0;
  }
  if (buffer != null) {
    long s = buffer.skip(n);
    if (s > 0) {
      n = s;
    } else {
      buffer = null;
      skip += n;
    }
  } else {
    skip += n;
  }
  pos += n;
  return n;
}

代码示例来源:origin: Alluxio/alluxio

@Override
public long skip(long n) {
 return mStream.skip(n);
}

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

@Override
public synchronized long skip(long arg0) {
 return getByteArrayInputStream().skip(arg0);
}

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

/**
 * Returns a byte[] containing all the bytes from a ByteArrayInputStream.
 * Where possible, this returns the actual array rather than a copy.
 */
private static byte[] exposeByteArrayInputStreamBytes(ByteArrayInputStream bais) {
  byte[] buffer;
  synchronized (bais) {
    byte[] buf;
    int pos;
    try {
      buf = (byte[]) BAIS_BUF.get(bais);
      pos = BAIS_POS.getInt(bais);
    } catch (IllegalAccessException iae) {
      throw new AssertionError(iae);
    }
    int available = bais.available();
    if (pos == 0 && buf.length == available) {
      buffer = buf;
    } else {
      buffer = new byte[available];
      System.arraycopy(buf, pos, buffer, 0, available);
    }
    bais.skip(available);
  }
  return buffer;
}

代码示例来源:origin: org.apache.poi/poi

@Override
public short readShort() {
  final int size = LittleEndianConsts.SHORT_SIZE;
  checkPosition(size);
  short le = LittleEndian.getShort(buf, pos);
  long skipped = super.skip(size);
  assert skipped == size : "Buffer overrun";
  return le;
}

代码示例来源:origin: org.apache.poi/poi

@Override
public int readInt() {
  final int size = LittleEndianConsts.INT_SIZE;
  checkPosition(size);
  int le = LittleEndian.getInt(buf, pos);
  long skipped = super.skip(size);
  assert skipped == size : "Buffer overrun";
  return le;
}

代码示例来源:origin: org.apache.poi/poi

@Override
public long readLong() {
  final int size = LittleEndianConsts.LONG_SIZE;
  checkPosition(size);
  long le = LittleEndian.getLong(buf, pos);
  long skipped = super.skip(size);
  assert skipped == size : "Buffer overrun";
  return le;
}

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

@Override
public void fromBytes(byte[] row) {
 ByteArrayInputStream baos = new ByteArrayInputStream(row);
 baos.skip(KeyUtil.HASH_PREFIX_SIZE);
 DataInputStream w = new DataInputStream(baos);
 try {
  type = w.readUTF();
  indicator = w.readUTF();
 } catch (IOException e) {
  throw new RuntimeException("Unable to convert type and indicator from bytes", e);
 }
}

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

public static Key fromBytes(byte[] buffer) throws IOException {
 ByteArrayInputStream baos = new ByteArrayInputStream(buffer);
 DataInputStream w = new DataInputStream(baos);
 baos.skip(KeyUtil.HASH_PREFIX_SIZE);
 return new Key(w.readUTF(), w.readUTF());
}

代码示例来源:origin: i2p/i2p.i2p

/** skip a little at a time, or sometimes zero */
  @Override
  public long skip(long n) {
    return super.skip(Math.min(n, r.nextInt(4)));
  }
}

代码示例来源:origin: com.liferay.portal/com.liferay.portal.kernel

byteArrayInputStream.skip(start);

代码示例来源:origin: AppliedEnergistics/Applied-Energistics-2

public PacketJEIRecipe( final ByteBuf stream ) throws IOException
{
  final ByteArrayInputStream bytes = this.getPacketByteArray( stream );
  bytes.skip( stream.readerIndex() );
  final NBTTagCompound comp = CompressedStreamTools.readCompressed( bytes );
  if( comp != null )
  {
    this.recipe = new ItemStack[9][];
    for( int x = 0; x < this.recipe.length; x++ )
    {
      final NBTTagList list = comp.getTagList( "#" + x, 10 );
      if( list.tagCount() > 0 )
      {
        this.recipe[x] = new ItemStack[list.tagCount()];
        for( int y = 0; y < list.tagCount(); y++ )
        {
          this.recipe[x][y] = new ItemStack( list.getCompoundTagAt( y ) );
        }
      }
    }
  }
}

代码示例来源:origin: org.jboss/jboss-serialization

public long skip(long n) throws IOException
{
  //testNextBytes();
  return byteStreamInput.skip(n);
}

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

totalBytes = 0;
  inputStream.skip(totalBytes);
  logger.log(Level.INFO, "totalBytes " + totalBytes);
} else {

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

public void seek(ByteArrayInputStream input, int position)
  throws IOException
{
  input.reset();
  input.skip(position);
}

代码示例来源:origin: org.jruby/jruby-complete

public synchronized SeekableByteChannel position(long newPosition) throws IOException {
  if ( newPosition < 0 ) {
    throw new IllegalArgumentException("negative new position: " + newPosition);
  }
  if ( newPosition > Integer.MAX_VALUE ) {
    throw new IllegalArgumentException("can not set new position: " + newPosition + " too big!");
  }
  this.in.reset(); // to initial mark (0 or offset)
  if ( newPosition > 0 ) this.in.skip(newPosition);
  //this.position = (int) newPosition;
  return this;
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

@Override
public int readInt() {
  final int size = LittleEndianConsts.INT_SIZE;
  checkPosition(size);
  int le = LittleEndian.getInt(buf, pos);
  long skipped = super.skip(size);
  assert skipped == size : "Buffer overrun";
  return le;
}

代码示例来源:origin: org.jruby/jruby-complete

@Override
public Channel getRemainingAsChannel() {
  ByteArrayInputStream bais = new ByteArrayInputStream(completeSource.unsafeBytes(), completeSource.begin(), completeSource.realSize());
  bais.skip(offset);
  return ChannelHelper.readableChannel(bais);
}

相关文章