Java 类java.io.DataInputStream 实例源码

项目:sstable-adaptor    文件:IndexSummary.java   
/**
 * 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);
}
项目:OpenJSharp    文件:BinaryAttribute.java   
/**
 * 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;
}
项目:hadoop    文件:BlockReceiver.java   
PacketResponder(final DataOutputStream upstreamOut,
    final DataInputStream downstreamIn, final DatanodeInfo[] downstreams) {
  this.downstreamIn = downstreamIn;
  this.upstreamOut = upstreamOut;

  this.type = downstreams == null? PacketResponderType.NON_PIPELINE
      : downstreams.length == 0? PacketResponderType.LAST_IN_PIPELINE
          : PacketResponderType.HAS_DOWNSTREAM_IN_PIPELINE;

  final StringBuilder b = new StringBuilder(getClass().getSimpleName())
      .append(": ").append(block).append(", type=").append(type);
  if (type != PacketResponderType.HAS_DOWNSTREAM_IN_PIPELINE) {
    b.append(", downstreams=").append(downstreams.length)
        .append(":").append(Arrays.asList(downstreams));
  }
  this.myString = b.toString();
}
项目:iBase4J-Common    文件:WeiXinUserUtils.java   
public static String getUserList(String next_openid) {
    String token = WeiXinUtils.getToken();
    if (token != null) {
        String urlString = "https://api.weixin.qq.com/cgi-bin/user/get?access_token=" + token;
        if (next_openid != null) {
            urlString = urlString + "&next_openid=" + next_openid;
        }
        try {
            URL url = new URL(urlString);
            HttpsURLConnection httpsURLConnection = (HttpsURLConnection) url.openConnection();
            httpsURLConnection.setDoInput(true);
            DataInputStream dataInputStream = new DataInputStream(httpsURLConnection.getInputStream());
            StringBuffer stringBuffer = new StringBuffer();
            int inputByte = dataInputStream.read();
            while (inputByte != -1) {
                stringBuffer.append((char) inputByte);
                inputByte = dataInputStream.read();
            }
            String kfString = stringBuffer.toString();
            return kfString;
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    return null;
}
项目:rskj    文件:TrieImplTrieSerializationTests.java   
@Test
public void serializeTrieWithTwoValues() throws IOException {
    Trie trie = new TrieImpl()
            .put("foo".getBytes(), "bar".getBytes())
            .put("bar".getBytes(), "foo".getBytes());

    byte[] bytes = ((TrieImpl)trie).serializeTrie();

    Assert.assertNotNull(bytes);

    byte[] message = trie.toMessage();

    ByteArrayInputStream bstream = new ByteArrayInputStream(bytes);
    DataInputStream ostream = new DataInputStream(bstream);

    Assert.assertEquals(0, ostream.readShort());
    Assert.assertEquals(2, ostream.readShort());
    Assert.assertEquals(message.length, ostream.readInt());
}
项目:OpenDiabetes    文件:Result.java   
public void readAdditionalResults(SessionInterface session,
                                  DataInputStream inputStream,
                                  RowInputBinary in) throws IOException {

    Result currentResult = this;

    setSession(session);

    while (true) {
        int addedResultMode = inputStream.readByte();

        if (addedResultMode == ResultConstants.NONE) {
            return;
        }

        currentResult = newResult(null, inputStream, in, addedResultMode);

        addChainedResult(currentResult);
    }
}
项目:openjdk-jdk10    文件:Basic.java   
@Test(dataProvider = "knownClassFiles")
public void testKnownClassFiles(String path, boolean theDefault) throws Exception {
    if (isExplodedBuild && !theDefault) {
        System.out.println("Skip testKnownClassFiles with non-default FileSystem");
        return;
    }

    FileSystem fs = selectFileSystem(theDefault);
    Path classFile = fs.getPath(path);

    assertTrue(Files.isRegularFile(classFile));
    assertTrue(Files.size(classFile) > 0L);

    // check magic number
    try (InputStream in = Files.newInputStream(classFile)) {
        int magic = new DataInputStream(in).readInt();
        assertEquals(magic, 0xCAFEBABE);
    }
}
项目:monarch    文件:MTableOverflowToTierTest.java   
@Override
public Object call() throws Exception {
  MCacheFactory.getAnyInstance().getResourceManager()
      .setEvictionHeapPercentage(EVICT_HEAP_PCT);
  final PartitionedRegion pr =
      (PartitionedRegion) MCacheFactory.getAnyInstance().getRegion(TABLE_NAME);
  if (debug)
    System.out.println("MTableOverflowToTierTest.call YYYYYYYYYYYYYYYY");
  assertNotNull(pr);
  int count = 0;
  /** get the total count of number of entries from overflow-tier **/
  for (final BucketRegion br : pr.getDataStore().getAllLocalBucketRegions()) {
    FileInputStream fis = new FileInputStream(TierHelper.getTierFileNameKeys(br));
    DataInputStream dis = new DataInputStream(new BufferedInputStream(fis, 32768));
    while (dis.available() > 0) {
      DataSerializer.readObject(dis);
      count++;
    }
    dis.close();
  }
  return count;
}
项目:lastpass-java    文件:ParserHelper.java   
public List<Chunk> ExtractChunks(DataInputStream reader) {
    List<Chunk> chunks = new ArrayList<>();
    try
    {
        boolean stopped = false;
        while (!stopped) {
            chunks.add(ReadChunk(reader));
        }
    }
    catch (Exception e)
    {
        // In case the stream is truncated we just ignore the incomplete chunk.
        if (!(e.getCause() instanceof IOException)) {
            throw e;
        }
    }

    return chunks;
}
项目:hadoop    文件:TFile.java   
/**
 * Constructor
 * 
 * @param reader
 *          The TFile reader object.
 * @param begin
 *          Begin location of the scan.
 * @param end
 *          End location of the scan.
 * @throws IOException
 */
Scanner(Reader reader, Location begin, Location end) throws IOException {
  this.reader = reader;
  // ensure the TFile index is loaded throughout the life of scanner.
  reader.checkTFileDataIndex();
  beginLocation = begin;
  endLocation = end;

  valTransferBuffer = new BytesWritable();
  // TODO: remember the longest key in a TFile, and use it to replace
  // MAX_KEY_SIZE.
  keyBuffer = new byte[MAX_KEY_SIZE];
  keyDataInputStream = new DataInputBuffer();
  valueBufferInputStream = new ChunkDecoder();
  valueDataInputStream = new DataInputStream(valueBufferInputStream);

  if (beginLocation.compareTo(endLocation) >= 0) {
    currentLocation = new Location(endLocation);
  } else {
    currentLocation = new Location(0, 0);
    initBlock(beginLocation.getBlockIndex());
    inBlockAdvance(beginLocation.getRecordIndex());
  }
}
项目:rapidminer    文件:ExampleSetToStream.java   
/** Reads a single row from the stream. */
public void readRow(final DataInputStream in, final double[] data, final ColumnType[] columnTypes, final boolean sparse,
        final double[] sparseDefaults) throws IOException {
    if (sparse) {
        System.arraycopy(sparseDefaults, 0, data, 0, sparseDefaults.length);
        while (true) {
            int index = in.readInt();
            if (index == -1) {
                break;
            } else {
                data[index] = readDatum(in, columnTypes[index]);
            }
        }
    } else {
        for (int attIndex = 0; attIndex < columnTypes.length; attIndex++) {
            data[attIndex] = readDatum(in, columnTypes[attIndex]);
        }
    }
}
项目:BiglyBT    文件:DHTUDPPacketRequestPing.java   
protected
DHTUDPPacketRequestPing(
    DHTUDPPacketNetworkHandler      network_handler,
    DataInputStream                 is,
    long                            con_id,
    int                             trans_id )

    throws IOException
{
    super( network_handler, is,  DHTUDPPacketHelper.ACT_REQUEST_PING, con_id, trans_id );

    if ( getProtocolVersion() >= DHTTransportUDP.PROTOCOL_VERSION_ALT_CONTACTS ){

        DHTUDPUtils.deserialiseAltContactRequest( this, is );
    }

    super.postDeserialise(is);
}
项目:monarch    文件:JGroupsMessenger.java   
void filterIncomingMessage(DistributionMessage m) {
  switch (m.getDSFID()) {
    case JOIN_RESPONSE:
      JoinResponseMessage jrsp = (JoinResponseMessage) m;

      if (jrsp.getRejectionMessage() == null
          && services.getConfig().getTransport().isMcastEnabled()) {
        byte[] serializedDigest = jrsp.getMessengerData();
        ByteArrayInputStream bis = new ByteArrayInputStream(serializedDigest);
        DataInputStream dis = new DataInputStream(bis);
        try {
          Digest digest = new Digest();
          digest.readFrom(dis);
          logger.trace("installing JGroups message digest {}", digest);
          this.myChannel.getProtocolStack().getTopProtocol()
              .down(new Event(Event.MERGE_DIGEST, digest));
          jrsp.setMessengerData(null);
        } catch (Exception e) {
          logger.fatal("Unable to read JGroups messaging digest", e);
        }
      }
      break;
    default:
      break;
  }
}
项目:Hydroangeas    文件:MinecraftPingUtil.java   
/**
 * @author thinkofdeath
 * See: https://gist.github.com/thinkofdeath/e975ddee04e9c87faf22
 */
public static int readVarInt(DataInputStream in) throws IOException {
    int i = 0;
    int j = 0;
    while (true) {
        int k = in.readByte();

        i |= (k & 0x7F) << j++ * 7;

        if (j > 5)
            throw new RuntimeException("VarInt too big");

        if ((k & 0x80) != 128)
            break;
    }

    return i;
}
项目:Cubes    文件:Cave.java   
public static Cave read(DataInputStream inputStream) throws IOException {
  int caveStartX = inputStream.readInt();
  int caveStartY = inputStream.readInt();
  int caveStartZ = inputStream.readInt();
  int mapSize = inputStream.readInt();

  HashMap<AreaReference, int[]> blocks = new HashMap<AreaReference, int[]>();

  for (int i = 0; i < mapSize; i++) {
    int areaX = inputStream.readInt();
    int areaZ = inputStream.readInt();
    int valueLength = inputStream.readInt();

    AreaReference areaReference = new AreaReference().setFromAreaCoordinates(areaX, areaZ);
    int[] value = new int[valueLength];

    for (int j = 0; j < valueLength; j++) {
      value[j] = inputStream.readInt();
    }

    blocks.put(areaReference, value);
  }
  return new Cave(caveStartX, caveStartY, caveStartZ, blocks);
}
项目:googles-monorepo-demo    文件:LittleEndianDataOutputStreamTest.java   
@SuppressWarnings("deprecation") // testing a deprecated method
public void testWriteBytes() throws IOException {

  /* Write out various test values in LITTLE ENDIAN FORMAT */
  out.writeBytes("r\u00C9sum\u00C9");

  byte[] data = baos.toByteArray();

  /* Setup input streams */
  DataInput in = new DataInputStream(new ByteArrayInputStream(data));

  /* Read in various values NORMALLY */
  byte[] b = new byte[6];
  in.readFully(b);
  assertEquals("r\u00C9sum\u00C9".getBytes(Charsets.ISO_8859_1), b);
}
项目:hadoop    文件:EditLogFileInputStream.java   
/**
 * Read the header of fsedit log
 * @param in fsedit stream
 * @return the edit log version number
 * @throws IOException if error occurs
 */
@VisibleForTesting
static int readLogVersion(DataInputStream in, boolean verifyLayoutVersion)
    throws IOException, LogHeaderCorruptException {
  int logVersion;
  try {
    logVersion = in.readInt();
  } catch (EOFException eofe) {
    throw new LogHeaderCorruptException(
        "Reached EOF when reading log header");
  }
  if (verifyLayoutVersion &&
      (logVersion < HdfsConstants.NAMENODE_LAYOUT_VERSION || // future version
       logVersion > Storage.LAST_UPGRADABLE_LAYOUT_VERSION)) { // unsupported
    throw new LogHeaderCorruptException(
        "Unexpected version of the file system log file: "
        + logVersion + ". Current version = "
        + HdfsConstants.NAMENODE_LAYOUT_VERSION + ".");
  }
  return logVersion;
}
项目:incubator-netbeans    文件:LayerCacheManager.java   
@Override
public FileSystem load(FileSystem previous, ByteBuffer bb) throws IOException {
    byte[] arr = new byte[bb.limit()];
    bb.get(arr);
    DataInputStream is = new DataInputStream(new ByteArrayInputStream(arr));
    List<URL> urls = new ArrayList<URL>();
    while (is.available() > 0) {
        String u = is.readUTF();
        urls.add(new URL(u));
    }
    try {
        XMLFileSystem fs = (XMLFileSystem)previous;
        fs.setXmlUrls(urls.toArray(new URL[urls.size()]));
        return fs;
    } catch (PropertyVetoException pve) {
        throw (IOException) new IOException(pve.toString()).initCause(pve);
    }
}
项目:monarch    文件:DiskInitFile.java   
private PersistentMemberID bytesToPMID(byte[] bytes) {
  try {
    ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
    DataInputStream dis = new DataInputStream(bais);
    PersistentMemberID result = new PersistentMemberID();
    InternalDataSerializer.invokeFromData(result, dis);
    return result;
  } catch (IOException io) {
    throw new DiskAccessException(
        LocalizedStrings.Oplog_FAILED_READING_FILE_DURING_RECOVERY_FROM_0
            .toLocalizedString(this.ifFile.getPath()),
        io, this.parent);
  } catch (ClassNotFoundException cnf) {
    throw new DiskAccessException(
        LocalizedStrings.Oplog_FAILED_READING_FILE_DURING_RECOVERY_FROM_0
            .toLocalizedString(this.ifFile.getPath()),
        cnf, this.parent);
  }
}
项目:incubator-netbeans    文件:LocalVariableTableEntry.java   
private void loadLocalVariableEntry(DataInputStream in, ConstantPool pool) 
  throws IOException {
    startPC = in.readUnsignedShort();
    length = in.readUnsignedShort();
    Object o = pool.get(in.readUnsignedShort());
    if (!(o instanceof CPUTF8Info))
      throw new InvalidClassFormatException();
    CPUTF8Info entry = (CPUTF8Info)o;
    name = entry.getName();
    o = pool.get(in.readUnsignedShort());
    if (!(o instanceof CPUTF8Info))
      throw new InvalidClassFormatException();
    entry = (CPUTF8Info)o;
    description = entry.getName();
    index = in.readUnsignedShort();
}
项目:openjdk-jdk10    文件:DTD.java   
private AttributeList readAttributeList(DataInputStream in, String[] names)
                throws IOException  {
        AttributeList result = null;
        for (int num = in.readByte(); num > 0; --num) {
            short nameId = in.readShort();
            int type = in.readByte();
            int modifier = in.readByte();
            short valueId = in.readShort();
            String value = (valueId == -1) ? null : names[valueId];
            Vector<String> values = null;
            short numValues = in.readShort();
            if (numValues > 0) {
                values = new Vector<String>(numValues);
                for (int i = 0; i < numValues; i++) {
                    values.addElement(names[in.readShort()]);
                }
            }
result = new AttributeList(names[nameId], type, modifier, value,
                                       values, result);
            // We reverse the order of the linked list by doing this, but
            // that order isn't important.
        }
        return result;
    }
项目:incubator-netbeans    文件:Method.java   
/**
    * Returns the default annotation value for the element
    * defined by this method.  Null is returned if no default 
    * is specified for this element, or if the class that contains 
    * this method does not define an annotation type.
    */
   public ElementValue getAnnotationDefault() {
if (annotationDefault == notloadedAnnotationDefault) {
           annotationDefault = null;
    DataInputStream in = 
    attributes.getStream("AnnotationDefault"); // NOI18N
    if (in != null) {
    try {
        annotationDefault = 
        ElementValue.load(in, classFile.constantPool, false);
        in.close();
    } catch (IOException e) {
        throw new InvalidClassFileAttributeException("invalid AnnotationDefault attribute", e);
    }
    }
}
       return annotationDefault;
   }
项目:geomapapp    文件:HeatFlux.java   
static void load() throws IOException {
    q = new float[11][130][102];
    URL url = URLFactory.url(haxby.map.MapApp.TEMP_BASE_URL + "arctic/ice/heatflux");
    DataInputStream in = new DataInputStream(url.openStream());
    for( int year=0 ; year<11 ; year++ ) {
            for(int y=0 ; y<102 ; y++) {
        for(int x=0 ; x<130 ; x++) {
                q[year][x][y] = in.readFloat();
            }
        }
    }
    in.close();
    loaded = true;
}
项目:iBase4J    文件:WeiXinKFUtils.java   
/**
 * 添加客服帐号
 *
 * @param keFu
 * @return
 */
public static boolean insertKfAccount(KeFu keFu) {
    boolean isOk = false;
    String token = WeiXinUtils.getToken();
    if (token != null) {
        String urlString = "https://api.weixin.qq.com/customservice/kfaccount/add?access_token=" + token;
        try {
            URL url = new URL(urlString);
            HttpsURLConnection httpsURLConnection = (HttpsURLConnection) url.openConnection();
            String kfAccountString = JSONObject.toJSONString(keFu);
            httpsURLConnection.setRequestProperty("Content-length", String.valueOf(kfAccountString.length()));
            httpsURLConnection.setRequestProperty("Content-Type", "application/json");
            httpsURLConnection.setDoOutput(true);
            httpsURLConnection.setDoInput(true);
            DataOutputStream dataOutputStream = new DataOutputStream(httpsURLConnection.getOutputStream());
            dataOutputStream.write(kfAccountString.getBytes());
            dataOutputStream.flush();
            dataOutputStream.close();
            DataInputStream dataInputStream = new DataInputStream(httpsURLConnection.getInputStream());
            StringBuffer stringBuffer = new StringBuffer();
            int inputByte = dataInputStream.read();
            while (inputByte != -1) {
                stringBuffer.append((char) inputByte);
                inputByte = dataInputStream.read();
            }
            String kfString = stringBuffer.toString();
            JSONObject jsonObject = JSON.parseObject(kfString);
            if (jsonObject.containsKey("errcode")) {
                int errcode = jsonObject.getIntValue("errcode");
                if (errcode == 0) {
                    isOk = true;
                } else {
                    //TODO 添加客服账号失败
                    isOk = false;
                }
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    return isOk;
}
项目:openjdk-jdk10    文件:ClassfileBytecode.java   
@Override
public LocalVariableTable getLocalVariableTable() {
    if (localVariableTableBytes == null) {
        return null;
    }

    final int localVariableTableLength = localVariableTableBytes.length / LOCAL_VARIABLE_TABLE_SIZE_IN_BYTES;
    DataInputStream stream = new DataInputStream(new ByteArrayInputStream(localVariableTableBytes));
    Local[] locals = new Local[localVariableTableLength];

    for (int i = 0; i < localVariableTableLength; i++) {
        try {
            final int startBci = stream.readUnsignedShort();
            final int endBci = startBci + stream.readUnsignedShort();
            final int nameCpIndex = stream.readUnsignedShort();
            final int typeCpIndex = stream.readUnsignedShort();
            final int slot = stream.readUnsignedShort();

            String localName = constantPool.lookupUtf8(nameCpIndex);
            String localType = constantPool.lookupUtf8(typeCpIndex);

            ClassfileBytecodeProvider context = constantPool.context;
            Class<?> c = context.resolveToClass(localType);
            locals[i] = new Local(localName, context.metaAccess.lookupJavaType(c), startBci, endBci, slot);
        } catch (IOException e) {
            throw new GraalError(e);
        }
    }

    return new LocalVariableTable(locals);
}
项目:CoreX    文件:Chunk.java   
public static Chunk fromFastBinary(byte[] data, LevelProvider provider) {
    try {
        CompoundTag chunk = NBTIO.read(new DataInputStream(new ByteArrayInputStream(data)), ByteOrder.BIG_ENDIAN);
        if (!chunk.contains("Level") || !(chunk.get("Level") instanceof CompoundTag)) {
            return null;
        }

        return new Chunk(provider, chunk.getCompound("Level"));
    } catch (Exception e) {
        return null;
    }
}
项目:hadoop    文件:ZKDelegationTokenSecretManager.java   
private void processKeyAddOrUpdate(byte[] data) throws IOException {
  ByteArrayInputStream bin = new ByteArrayInputStream(data);
  DataInputStream din = new DataInputStream(bin);
  DelegationKey key = new DelegationKey();
  key.readFields(din);
  synchronized (this) {
    allKeys.put(key.getKeyId(), key);
  }
}
项目:Jupiter    文件:Chunk.java   
public static Chunk fromFastBinary(byte[] data, LevelProvider provider) {
    try {
        CompoundTag chunk = NBTIO.read(new DataInputStream(new ByteArrayInputStream(data)), ByteOrder.BIG_ENDIAN);
        if (!chunk.contains("Level") || !(chunk.get("Level") instanceof CompoundTag)) {
            return null;
        }

        return new Chunk(provider, chunk.getCompound("Level"));
    } catch (Exception e) {
        return null;
    }
}
项目:monarch    文件:AColumnStatisticsTest.java   
/**
 * Simple test that asserts the statistics are correctly stored for the types even with serialize
 * and de-serialize. Also assert that min changes accordingly when null values are passed as for
 * fixed length columns use default values.
 *
 * @throws IOException if not able to read/write
 * @throws ClassNotFoundException the class does not exist
 */
@Test
public void testStatisticsBasic() throws IOException, ClassNotFoundException {
  final Object[] values = new Object[] {1, 11.11, "abc_EFG", Date.valueOf("2017-10-10"),
      new Timestamp(123456789L), new Object[] {55L, 56L, 57L}};
  final String[] expected =
      new String[] {"1", "11.11", "abc_EFG", "2017-10-10", "1970-01-02 15:47:36.789", null};
  final String[] expectedMin =
      new String[] {"0", "0.0", "abc_EFG", "1970-01-01", "1970-01-01 05:30:00.0", null};

  final AColumnStatistics acs = new AColumnStatistics(TD);
  row.reset(null, enc.serializeValue(TD, record.reset(values)), enc, null);
  acs.updateRowStatistics(TD.getAllColumnDescriptors(), row);

  assertColumnStatistics(expected, expected, acs);

  final HeapDataOutputStream out = new HeapDataOutputStream(1024, null);
  DataSerializer.writeObject(acs, out);
  final byte[] dataBytes = out.toByteArray();

  AColumnStatistics ncs =
      DataSerializer.readObject(new DataInputStream(new ByteArrayInputStream(dataBytes)));

  assertColumnStatistics(expected, expected, ncs);

  row.reset(null, enc.serializeValue(TD, record.reset(new Object[TD.getNumOfColumns()])), enc,
      null);
  acs.updateRowStatistics(TD.getAllColumnDescriptors(), row);
  assertColumnStatistics(expectedMin, expected, acs);
}
项目:Reer    文件:BTreePersistentIndexedCache.java   
public void read(DataInputStream instr) throws IOException {
    int count = instr.readInt();
    entries.clear();
    for (int i = 0; i < count; i++) {
        IndexEntry entry = new IndexEntry();
        entry.hashCode = instr.readLong();
        entry.dataBlock = new BlockPointer(instr.readLong());
        entry.childIndexBlock = new BlockPointer(instr.readLong());
        entries.add(entry);
    }
    tailPos = new BlockPointer(instr.readLong());
}
项目:geomapapp    文件:USGS_DEM.java   
public void readHeader() throws IOException {
    DataInputStream in = zipped
        ? new DataInputStream(
            new GZIPInputStream( url.openStream() ))
        : new DataInputStream( url.openStream() );
    readHeader(in);
    in.close();
}
项目:fuck_zookeeper    文件:QuorumCnxManager.java   
RecvWorker(Socket sock, Long sid, SendWorker sw) {
    super("RecvWorker:" + sid);
    this.sid = sid;
    this.sock = sock;
    this.sw = sw;
    try {
        din = new DataInputStream(sock.getInputStream());
        // OK to wait until socket disconnects while reading.
        sock.setSoTimeout(0);
    } catch (IOException e) {
        LOG.error("Error while accessing socket for " + sid, e);
        closeSocket(sock);
        running = false;
    }
}
项目:hadoop-oss    文件:ZKDelegationTokenSecretManager.java   
private DelegationTokenInformation getTokenInfoFromZK(TokenIdent ident,
    boolean quiet) throws IOException {
  String nodePath =
      getNodePath(ZK_DTSM_TOKENS_ROOT,
          DELEGATION_TOKEN_PREFIX + ident.getSequenceNumber());
  try {
    byte[] data = zkClient.getData().forPath(nodePath);
    if ((data == null) || (data.length == 0)) {
      return null;
    }
    ByteArrayInputStream bin = new ByteArrayInputStream(data);
    DataInputStream din = new DataInputStream(bin);
    createIdentifier().readFields(din);
    long renewDate = din.readLong();
    int pwdLen = din.readInt();
    byte[] password = new byte[pwdLen];
    int numRead = din.read(password, 0, pwdLen);
    if (numRead > -1) {
      DelegationTokenInformation tokenInfo =
          new DelegationTokenInformation(renewDate, password);
      return tokenInfo;
    }
  } catch (KeeperException.NoNodeException e) {
    if (!quiet) {
      LOG.error("No node in path [" + nodePath + "]");
    }
  } catch (Exception ex) {
    throw new IOException(ex);
  }
  return null;
}
项目:angel    文件:ServerMatrix.java   
/**
 * Read partitions of matrix from input
 *
 * @param input the input
 * @throws IOException
 */
public void readSnapshot(DataInputStream input) throws IOException {
  int partitionNum = input.readInt();
  LOG.info("partitionNum=" + partitionNum);
  if (LOG.isDebugEnabled()) {
    LOG.debug("readFrom input, matrixId: " + matrixId + ", partitionNum: " + partitionNum);
  }
  for (int i = 0; i < partitionNum; i++) {
    int partitionId = input.readInt();
    LOG.debug("parse partitionId: " + partitionId);
    partitionMaps.get(partitionId).load(input);
  }
}
项目:LT-ABSA    文件:GloVeSpace.java   
/**
 * Read a Vector - Array from binary file
 * @param ds input data stream
 * @param vectorSize length of each word vector
 * @return an array of float containing the word vector representation
 */
private static float[] readFloatVector(DataInputStream ds, int vectorSize) throws IOException {
    float[] vector = new float[vectorSize];
    for (int j = 0; j < vectorSize; j++) {
        long l = ds.readLong();
        float d = (float)(Long.reverseBytes(l));
        vector[j] = d;
    }
    return vector;
}
项目:phonk    文件:PBluetoothServer.java   
ConnectionThread(ConnectedDevice connectedDevice) {
    mmConectedDevice = connectedDevice;
    mmBtSocketClient = connectedDevice.bluetoothSocket;
    try {
        outputStream = mmBtSocketClient.getOutputStream();
        inputStream = mmBtSocketClient.getInputStream();
        dataInputStream = new DataInputStream(inputStream);
    } catch (IOException e) {
        e.printStackTrace();
    }
    MLog.d(TAG, "bbt start connection thread " + inputStream + " " + dataInputStream + " " + outputStream);
}
项目:Brevent    文件:BreventProtocol.java   
@WorkerThread
public static boolean checkPortSync() throws IOException {
    try (
            Socket socket = new Socket(InetAddress.getLoopbackAddress(), BreventProtocol.PORT);
            DataOutputStream os = new DataOutputStream(socket.getOutputStream());
            DataInputStream is = new DataInputStream(socket.getInputStream())
    ) {
        os.writeShort(0);
        os.flush();
        return BreventProtocol.readFrom(is) == BreventOK.INSTANCE;
    }
}
项目:ditb    文件:IndexTableRelation.java   
public static IndexTableRelation getIndexTableRelation(HTableDescriptor desc) throws IOException {
  byte[] bytes;
  if (desc != null && (bytes = desc.getValue(INDEX_ATTRIBUTE_NAME_BYTES)) != null) {
    ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
    DataInputStream dis = new DataInputStream(inputStream);
    IndexTableRelation rl = new IndexTableRelation(desc.getTableName(), IndexType.NoIndex);
    rl.readFields(dis);
    return rl;
  }
  LOG.info("index table relation = null, because " + (desc == null ?
      "desc is null" :
      ("attribute is null for table " + desc.getTableName())));
  return null;
}
项目:KraftigAudio    文件:Oscilloscope.java   
@Override
public void load(DataInputStream in) throws IOException
{
    super.load(in);
    modeRadio.load(in);
    brightnessKnob.load(in);
}
项目:JRF    文件:MsgAck.java   
@Override
protected void decode(byte[] buf) throws IOException {
    try (DataInputStream dis = new DataInputStream(new ByteArrayInputStream(buf))) {
        fileID = dis.readShort();
        code = dis.readLong();
        int n = dis.readInt();
        if (n < 0)
            msg = null;
        else if (n == 0)
            msg = "";
        else
            msg = Utils.readString(dis);
    }
}