Package java.io

Examples of java.io.DataOutput


                dataOut.writeByte(type);
                bs.marshal(dataOut);
                dsm.tightMarshal2(this, c, dataOut, bs);

            } else {
                DataOutput looseOut = dataOut;

                if (!sizePrefixDisabled) {
                    bytesOut.restart();
                    looseOut = bytesOut;
                }

                looseOut.writeByte(type);
                dsm.looseMarshal(this, c, looseOut);

                if (!sizePrefixDisabled) {
                    Buffer sequence = bytesOut.toBuffer();
                    dataOut.writeInt(sequence.getLength());
View Full Code Here


        headers.add("key1", "value1");
        headers.add("key1", "value2");
        headers.add("key2", "value3");

        ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
        DataOutput out = new DataOutputStream(byteStream);
        headers.write(out);
       
        HttpHeaders newHeaders = new HttpHeaders();
        DataInput in = new DataInputStream(new ByteArrayInputStream(byteStream.toByteArray()));
        newHeaders.readFields(in);
View Full Code Here

    }

    public static void roundtrip(Writable wn1, Writable wn2)
            throws IOException {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        DataOutput out=new DataOutputStream(bos);
        wn1.write(out);
        byte[] result=bos.toByteArray();
        ByteArrayInputStream bis = new ByteArrayInputStream(result);
        DataInput in=new DataInputStream(bis);
        wn2.readFields(in);
View Full Code Here

     */
    @Test
    public void stress_write() throws Exception {
        int count = 10000000;
        DecimalOption option = new DecimalOption(new BigDecimal("3.14"));
        DataOutput out = new DataOutputStream(new NullOutputStream());
        for (int i = 0; i < count; i++) {
            option.write(out);
        }
    }
View Full Code Here

   * @return A decimal response code
   * @throws GeneralSecurityException If a JCE exception occur
   */
  public String generateResponseCode(long challenge) {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    DataOutput dout = new DataOutputStream(out);
    try {
      dout.writeLong(challenge);
    } catch (IOException e) {
      // This should never happen with a ByteArrayOutputStream
      throw new RuntimeException("Unexpected IOException");
    }
    byte[] value = out.toByteArray();
View Full Code Here

  public void testWritable() throws Exception {

    Random rng = RandomUtils.getRandom();
    ByteArrayOutputStream byteOutStream = new ByteArrayOutputStream();
    DataOutput out = new DataOutputStream(byteOutStream);

    int n = 10;
    for (int nloop=0; nloop< n; nloop++) {
      byteOutStream.reset();
     
View Full Code Here

        Tuple t1 = giveMeOneOfEach();

        File file = File.createTempFile("Tuple", "put");
        FileOutputStream fos = new FileOutputStream(file);
        DataOutput out = new DataOutputStream(fos);
        t1.write(out);
        t1.write(out); // twice in a row on purpose
        fos.close();

        FileInputStream fis = new FileInputStream(file);
View Full Code Here

        map.put(new Long(3L), new String("all"));
        t1.set(0, map);

        File file = File.createTempFile("Tuple", "put");
        FileOutputStream fos = new FileOutputStream(file);
        DataOutput out = new DataOutputStream(fos);
        t1.write(out);
        fos.close();

        FileInputStream fis = new FileInputStream(file);
        DataInput in = new DataInputStream(fis);
View Full Code Here

      // write the root level
      long rootLevelIndexPos = out.getPos();

      {
        DataOutput blockStream =
            blockWriter.startWriting(BlockType.ROOT_INDEX);
        rootChunk.writeRoot(blockStream);
        if (midKeyMetadata != null)
          blockStream.write(midKeyMetadata);
        blockWriter.writeHeaderAndData(out);
      }

      // Add root index block size
      totalBlockOnDiskSize += blockWriter.getOnDiskSizeWithoutHeader();
View Full Code Here

    get.setAttribute("attribute1", Bytes.toBytes("value1"));
    get.setAttribute("attribute2", Bytes.toBytes("value2"));
    get.setAttribute("attribute3", Bytes.toBytes("value3"));

    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    DataOutput out = new DataOutputStream(byteArrayOutputStream);
    get.write(out);

    Get get2 = new Get();
    Assert.assertTrue(get2.getAttributesMap().isEmpty());
View Full Code Here

TOP

Related Classes of java.io.DataOutput

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.