当前位置: 首页>>代码示例>>Java>>正文


Java DataInputStream.skipBytes方法代码示例

本文整理汇总了Java中java.io.DataInputStream.skipBytes方法的典型用法代码示例。如果您正苦于以下问题:Java DataInputStream.skipBytes方法的具体用法?Java DataInputStream.skipBytes怎么用?Java DataInputStream.skipBytes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.io.DataInputStream的用法示例。


在下文中一共展示了DataInputStream.skipBytes方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deserializeFirstLastKey

import java.io.DataInputStream; //导入方法依赖的package包/类
/**
 * Deserializes the first and last key stored in the summary
 *
 * Only for use by offline tools like SSTableMetadataViewer, otherwise SSTable.first/last should be used.
 */
public Pair<DecoratedKey, DecoratedKey> deserializeFirstLastKey(DataInputStream in, IPartitioner partitioner, boolean haveSamplingLevel) throws IOException
{
    in.skipBytes(4); // minIndexInterval
    int offsetCount = in.readInt();
    long offheapSize = in.readLong();
    if (haveSamplingLevel)
        in.skipBytes(8); // samplingLevel, fullSamplingSummarySize

    in.skip(offsetCount * 4);
    in.skip(offheapSize - offsetCount * 4);

    DecoratedKey first = partitioner.decorateKey(ByteBufferUtil.readWithLength(in));
    DecoratedKey last = partitioner.decorateKey(ByteBufferUtil.readWithLength(in));
    return Pair.create(first, last);
}
 
开发者ID:Netflix,项目名称:sstable-adaptor,代码行数:21,代码来源:IndexSummary.java

示例2: load

import java.io.DataInputStream; //导入方法依赖的package包/类
/**
 * Load a list of attributes
 */
public static BinaryAttribute load(DataInputStream in, BinaryConstantPool cpool, int mask) throws IOException {
    BinaryAttribute atts = null;
    int natt = in.readUnsignedShort();  // JVM 4.6 method_info.attrutes_count

    for (int i = 0 ; i < natt ; i++) {
        // id from JVM 4.7 attribute_info.attribute_name_index
        Identifier id = cpool.getIdentifier(in.readUnsignedShort());
        // id from JVM 4.7 attribute_info.attribute_length
        int len = in.readInt();

        if (id.equals(idCode) && ((mask & ATT_CODE) == 0)) {
            in.skipBytes(len);
        } else {
            byte data[] = new byte[len];
            in.readFully(data);
            atts = new BinaryAttribute(id, data, atts);
        }
    }
    return atts;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:BinaryAttribute.java

示例3: readAnnotation

import java.io.DataInputStream; //导入方法依赖的package包/类
/**
 * Read annotation entry from classfile.
 */
private String readAnnotation(final DataInputStream inp, final Object[] constantPool) throws Exception {

    final String annotationFieldDescriptor = readRefdString(inp, constantPool);
    String annotationClassName;
    if (annotationFieldDescriptor.charAt(0) == 'L'
            && annotationFieldDescriptor.charAt(annotationFieldDescriptor.length() - 1) == ';') {
        // Lcom/xyz/Annotation; -> com.xyz.Annotation
        annotationClassName = annotationFieldDescriptor.substring(1, annotationFieldDescriptor.length() - 1)
                .replace('/', '.');
    }
    else {
        // Should not happen
        annotationClassName = annotationFieldDescriptor;
    }
    final int numElementValuePairs = inp.readUnsignedShort();
    for (int i = 0; i < numElementValuePairs; i++) {
        inp.skipBytes(2); // element_name_index
        readAnnotationElementValue(inp, constantPool);
    }
    return annotationClassName;
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:25,代码来源:ClassGraphBuilder.java

示例4: getInputStream

import java.io.DataInputStream; //导入方法依赖的package包/类
public InputStream getInputStream(TinkerZipEntry entry) throws IOException {
    entry = getEntry(entry.getName());
    if (entry == null) {
        return null;
    }
    InputStream rafStream;
    RandomAccessFile localRaf = this.raf;
    synchronized (localRaf) {
        rafStream = new RAFStream(localRaf, entry.localHeaderRelOffset);
        DataInputStream is = new DataInputStream(rafStream);
        int localMagic = Integer.reverseBytes(is.readInt());
        if (((long) localMagic) != ZipConstants.LOCSIG) {
            throwZipException(this.filename, localRaf.length(), entry.getName(), entry
                    .localHeaderRelOffset, "Local File Header", localMagic);
        }
        is.skipBytes(2);
        int gpbf = Short.reverseBytes(is.readShort()) & 65535;
        if ((gpbf & 1) != 0) {
            throw new ZipException("Invalid General Purpose Bit Flag: " + gpbf);
        }
        is.skipBytes(18);
        int fileNameLength = Short.reverseBytes(is.readShort()) & 65535;
        int extraFieldLength = Short.reverseBytes(is.readShort()) & 65535;
        is.close();
        rafStream.skip((long) (fileNameLength + extraFieldLength));
        if (entry.compressionMethod == 0) {
            rafStream.endOffset = rafStream.offset + entry.size;
        } else {
            rafStream.endOffset = rafStream.offset + entry.compressedSize;
        }
    }
    return rafStream;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:34,代码来源:TinkerZipFile.java

示例5: processBlocks

import java.io.DataInputStream; //导入方法依赖的package包/类
/**
 * Process the blocks section of the fsimage.
 *
 * @param in Datastream to process
 * @param v Visitor to walk over inodes
 * @param skipBlocks Walk over each block?
 */
private void processBlocks(DataInputStream in, ImageVisitor v,
    int numBlocks, boolean skipBlocks) throws IOException {
  v.visitEnclosingElement(ImageElement.BLOCKS,
                          ImageElement.NUM_BLOCKS, numBlocks);
  
  // directory or symlink or reference node, no blocks to process    
  if(numBlocks < 0) { 
    v.leaveEnclosingElement(); // Blocks
    return;
  }
  
  if(skipBlocks) {
    int bytesToSkip = ((Long.SIZE * 3 /* fields */) / 8 /*bits*/) * numBlocks;
    if(in.skipBytes(bytesToSkip) != bytesToSkip)
      throw new IOException("Error skipping over blocks");
    
  } else {
    for(int j = 0; j < numBlocks; j++) {
      v.visitEnclosingElement(ImageElement.BLOCK);
      v.visit(ImageElement.BLOCK_ID, in.readLong());
      v.visit(ImageElement.NUM_BYTES, in.readLong());
      v.visit(ImageElement.GENERATION_STAMP, in.readLong());
      v.leaveEnclosingElement(); // Block
    }
  }
  v.leaveEnclosingElement(); // Blocks
}
 
开发者ID:naver,项目名称:hadoop,代码行数:35,代码来源:ImageLoaderCurrent.java

示例6: getInputStream

import java.io.DataInputStream; //导入方法依赖的package包/类
/**
 * Returns an input stream on the data of the specified {@code ZipEntry}.
 *
 * @param entry
 *            the ZipEntry.
 * @return an input stream of the data contained in the {@code ZipEntry}.
 * @throws IOException
 *             if an {@code IOException} occurs.
 * @throws IllegalStateException if this zip file has been closed.
 */
public InputStream getInputStream(TinkerZipEntry entry) throws IOException {
    // Make sure this ZipEntry is in this Zip file.  We run it through the name lookup.
    entry = getEntry(entry.getName());
    if (entry == null) {
        return null;
    }
    // Create an InputStream at the right part of the file.
    RandomAccessFile localRaf = raf;
    synchronized (localRaf) {
        // We don't know the entry data's start position. All we have is the
        // position of the entry's local header.
        // http://www.pkware.com/documents/casestudies/APPNOTE.TXT
        RAFStream rafStream = new RAFStream(localRaf, entry.localHeaderRelOffset);
        DataInputStream is = new DataInputStream(rafStream);
        final int localMagic = Integer.reverseBytes(is.readInt());
        if (localMagic != LOCSIG) {
            throwZipException(filename, localRaf.length(), entry.getName(), entry.localHeaderRelOffset, "Local File Header", localMagic);
        }
        is.skipBytes(2);
        // At position 6 we find the General Purpose Bit Flag.
        int gpbf = Short.reverseBytes(is.readShort()) & 0xffff;
        if ((gpbf & TinkerZipFile.GPBF_UNSUPPORTED_MASK) != 0) {
            throw new ZipException("Invalid General Purpose Bit Flag: " + gpbf);
        }
        // Offset 26 has the file name length, and offset 28 has the extra field length.
        // These lengths can differ from the ones in the central header.
        is.skipBytes(18);
        int fileNameLength = Short.reverseBytes(is.readShort()) & 0xffff;
        int extraFieldLength = Short.reverseBytes(is.readShort()) & 0xffff;
        is.close();
        // Skip the variable-size file name and extra field data.
        rafStream.skip(fileNameLength + extraFieldLength);
        /*if (entry.compressionMethod == ZipEntry.STORED) {
            rafStream.endOffset = rafStream.offset + entry.size;
            return rafStream;
        } else {
            rafStream.endOffset = rafStream.offset + entry.compressedSize;
            int bufSize = Math.max(1024, (int) Math.min(entry.getSize(), 65535L));
            return new ZipInflaterInputStream(rafStream, new Inflater(true), bufSize, entry);
        }*/
        if (entry.compressionMethod == TinkerZipEntry.STORED) {
            rafStream.endOffset = rafStream.offset + entry.size;
        } else {
            rafStream.endOffset = rafStream.offset + entry.compressedSize;
        }
        return rafStream;
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:59,代码来源:TinkerZipFile.java

示例7: readAnnotationElementValue

import java.io.DataInputStream; //导入方法依赖的package包/类
/**
 * Read annotation element value from classfile.
 */
// --------------------------------CreditEase Modified START----------------------------
private void readAnnotationElementValue(final DataInputStream inp, final Object[] constantPool) throws Exception {

    // --------------------------------CreditEase Modified END----------------------------
    final int tag = inp.readUnsignedByte();
    switch (tag) {
        case 'B':
        case 'C':
        case 'D':
        case 'F':
        case 'I':
        case 'J':
        case 'S':
        case 'Z':
        case 's':
            // const_value_index
            inp.skipBytes(2);
            break;
        case 'e':
            // enum_const_value
            inp.skipBytes(4);
            break;
        case 'c':
            // class_info_index
            inp.skipBytes(2);
            break;
        case '@':
            // Complex (nested) annotation
            readAnnotation(inp, constantPool);
            break;
        case '[':
            // array_value
            final int count = inp.readUnsignedShort();
            for (int l = 0; l < count; ++l) {
                // Nested annotation element value
                readAnnotationElementValue(inp, constantPool);
            }
            break;
        default:
            // System.err.println("Invalid annotation element type tag: 0x" + Integer.toHexString(tag));
            break;
    }
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:47,代码来源:ClassGraphBuilder.java

示例8: readHeader

import java.io.DataInputStream; //导入方法依赖的package包/类
public static final byte[] readHeader(InputStream inputStream,
                                    byte dataFormatIDExpected[],
                                    Authenticate authenticate)
                                                      throws IOException
{
    DataInputStream input = new DataInputStream(inputStream);
    char headersize = input.readChar();
    int readcount = 2;
    //reading the header format
    byte magic1 = input.readByte();
    readcount ++;
    byte magic2 = input.readByte();
    readcount ++;
    if (magic1 != MAGIC1 || magic2 != MAGIC2) {
        throw new IOException(MAGIC_NUMBER_AUTHENTICATION_FAILED_);
    }

    input.readChar(); // reading size
    readcount += 2;
    input.readChar(); // reading reserved word
    readcount += 2;
    byte bigendian    = input.readByte();
    readcount ++;
    byte charset      = input.readByte();
    readcount ++;
    byte charsize     = input.readByte();
    readcount ++;
    input.readByte(); // reading reserved byte
    readcount ++;

    byte dataFormatID[] = new byte[4];
    input.readFully(dataFormatID);
    readcount += 4;
    byte dataVersion[] = new byte[4];
    input.readFully(dataVersion);
    readcount += 4;
    byte unicodeVersion[] = new byte[4];
    input.readFully(unicodeVersion);
    readcount += 4;
    if (headersize < readcount) {
        throw new IOException("Internal Error: Header size error");
    }
    input.skipBytes(headersize - readcount);

    if (bigendian != BIG_ENDIAN_ || charset != CHAR_SET_
        || charsize != CHAR_SIZE_
        || !Arrays.equals(dataFormatIDExpected, dataFormatID)
        || (authenticate != null
            && !authenticate.isDataVersionAcceptable(dataVersion))) {
        throw new IOException(HEADER_AUTHENTICATION_FAILED_);
    }
    return unicodeVersion;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:54,代码来源:ICUBinary.java

示例9: printAllContents

import java.io.DataInputStream; //导入方法依赖的package包/类
public void printAllContents() throws IOException{
       DataInputStream data_in = new DataInputStream(new FileInputStream(f));
       // record block info section
       data_in.skipBytes( (int) (_record_block_offset+_number_width*4+_num_record_blocks*2*_number_width));
       
       // actual record block data
       //int i = (int) (position-infoI.num_entries_accumulator);//处于当前record块的第几个
       //record_info_struct RinfoI = _record_info_struct_list[accumulation_RecordB_tree.xxing(new mdict.myCpr(infoI.key_offsets[i],1)).getKey().value];
       
       
       //whole section of record_blocks;
       for(int i=0; i<_record_info_struct_list.length; i++){
       	record_info_struct RinfoI = _record_info_struct_list[i];
       	//data_in.skipBytes((int) RinfoI.compressed_size_accumulator);
       	long compressed_size = RinfoI.compressed_size;
       	long decompressed_size = RinfoI.decompressed_size;//用于验证
       	byte[] record_block_compressed = new byte[(int) compressed_size];
       	data_in.read(record_block_compressed);//+8 TODO optimize
           // 4 bytes indicates block compression type
       	byte[] record_block_type = new byte[4];
       	System.arraycopy(record_block_compressed, 0, record_block_type, 0, 4);
       	String record_block_type_str = new String(record_block_type);
       	// 4 bytes adler checksum of uncompressed content
       	ByteBuffer sf1 = ByteBuffer.wrap(record_block_compressed);
           int adler32 = sf1.order(ByteOrder.BIG_ENDIAN).getInt(4);
           byte[] record_block = new byte[1];
           // no compression
           if(record_block_type_str.equals(new String(new byte[]{0,0,0,0}))){
           	record_block = new byte[(int) (compressed_size-8)];
           	System.arraycopy(record_block_compressed, 8, record_block, 0, record_block.length-8);
           }
           // lzo compression
           else if(record_block_type_str.equals(new String(new byte[]{1,0,0,0}))){
               long st=System.currentTimeMillis(); //获取开始时间 
               record_block = new byte[(int) decompressed_size];
               MInt len = new MInt((int) decompressed_size);
               byte[] arraytmp = new byte[(int) compressed_size];
               System.arraycopy(record_block_compressed, 8, arraytmp, 0,(int) (compressed_size-8));
               MiniLZO.lzo1x_decompress(arraytmp,(int) compressed_size,record_block,len);
           	//System.out.println("get Record LZO decompressing key blocks done!") ;
               //System.out.println("解压Record耗时:"+(System.currentTimeMillis()-st));
           }
           // zlib compression
           else if(record_block_type_str.equals(new String(new byte[]{02,00,00,00}))){
               record_block = zlib_decompress(record_block_compressed,8);
           }
           // notice not that adler32 return signed value
           assert(adler32 == (calcChecksum(record_block) ));
           assert(record_block.length == decompressed_size );
//当前内容块解压完毕
           

           String record_str = new String(record_block,_encoding); 	
           // substitute styles
           //if self._substyle and self._stylesheet:
           //    record = self._substitute_stylesheet(record);
           show(record_str);       
       	
       	
       }
   }
 
开发者ID:KnIfER,项目名称:mdict-parser-java,代码行数:62,代码来源:mdict.java


注:本文中的java.io.DataInputStream.skipBytes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。