Package java.io

Examples of java.io.ByteArrayInputStream.available()


                  if (columnType.get(i) == Types.INTEGER || columnType.get(i) == Types.BIGINT
                     || columnType.get(i) == Types.SMALLINT || columnType.get(i) == Types.TINYINT)
                  {
                     ByteArrayInputStream ba = (ByteArrayInputStream)stream;
                     byte[] readBuffer = new byte[ba.available()];
                     ba.read(readBuffer);

                     String value = new String(readBuffer, Constants.DEFAULT_ENCODING);
                     insertNode.setLong(targetIndex + 1, Integer.parseInt(value));
                  }
View Full Code Here


                     insertNode.setLong(targetIndex + 1, Integer.parseInt(value));
                  }
                  else if (columnType.get(i) == Types.BIT)
                  {
                     ByteArrayInputStream ba = (ByteArrayInputStream)stream;
                     byte[] readBuffer = new byte[ba.available()];
                     ba.read(readBuffer);

                     String value = new String(readBuffer);
                     if (dialect.equalsIgnoreCase(DBConstants.DB_DIALECT_PGSQL))
                     {
View Full Code Here

                     }
                  }
                  else if (columnType.get(i) == Types.BOOLEAN)
                  {
                     ByteArrayInputStream ba = (ByteArrayInputStream)stream;
                     byte[] readBuffer = new byte[ba.available()];
                     ba.read(readBuffer);

                     String value = new String(readBuffer);
                     insertNode.setBoolean(targetIndex + 1, value.equalsIgnoreCase("true"));
                  }
View Full Code Here

         if (size < splitFactor)
         {
            byte[] newSplit = new byte[size];
            System.arraycopy(splitElement, 0, newSplit, 0, size);

            packet = new FakePacket(1, newSplit, input.available() > 0, false);
         }
         else
         {
            packet = new FakePacket(1, splitElement, input.available() > 0, false);
         }
View Full Code Here

            packet = new FakePacket(1, newSplit, input.available() > 0, false);
         }
         else
         {
            packet = new FakePacket(1, splitElement, input.available() > 0, false);
         }

         outBuffer.addPacket(packet);
      }
View Full Code Here

                expectedResult.length, in);
        assertEquals(expectedResult.length, result.length);
        for (int i = 0; i < expectedResult.length; i++) {
            assertEquals(expectedResult[i], result[i]);
        }
        assertEquals(0, in.available());
    }

}
View Full Code Here

        ByteArrayInputStream bais = new ByteArrayInputStream(new byte[] {
                (byte) 192, 0, (byte) 192, 0 });
        assertEquals(192, runCodec.decode(bais));
        assertEquals(192, runCodec.decode(bais));
        assertEquals(0, runCodec.decode(bais));
        assertEquals(0, bais.available());
        runCodec = new RunCodec(1, Codec.BYTE1, Codec.UNSIGNED5);
        bais = new ByteArrayInputStream(new byte[] { (byte) 192, 0, (byte) 192,
                0 });
        assertEquals(192, runCodec.decode(bais));
        assertEquals(0, runCodec.decode(bais));
View Full Code Here

        bais = new ByteArrayInputStream(new byte[] { (byte) 192, 0, (byte) 192,
                0 });
        assertEquals(192, runCodec.decode(bais));
        assertEquals(0, runCodec.decode(bais));
        assertEquals(192, runCodec.decode(bais));
        assertEquals(0, bais.available());
    }

    public void testUnsigned5() throws Exception {
        decode(Codec.UNSIGNED5, new byte[] { 1 }, 1, 0);
        decode(Codec.UNSIGNED5, new byte[] { (byte) 191 }, 191, 0);
View Full Code Here

        byte[] buffer = "1234567890".getBytes("UTF-8");

        BufferedOutputStream buffos = new BufferedOutputStream(byteArrayos, 5);
        buffos.write(buffer, 0, 4);
        byteArrayis = new ByteArrayInputStream(byteArrayos.toByteArray());
        assertEquals("Bytes written, not buffered", 0, byteArrayis.available());
        buffos.flush();
        byteArrayis = new ByteArrayInputStream(byteArrayos.toByteArray());
        assertEquals("Bytes not written after flush", 4, byteArrayis
                .available());
        for (int i = 0; i < 4; i++) {
View Full Code Here

        buffos.write(buffer, 0, 4);
        byteArrayis = new ByteArrayInputStream(byteArrayos.toByteArray());
        assertEquals("Bytes written, not buffered", 0, byteArrayis.available());
        buffos.flush();
        byteArrayis = new ByteArrayInputStream(byteArrayos.toByteArray());
        assertEquals("Bytes not written after flush", 4, byteArrayis
                .available());
        for (int i = 0; i < 4; i++) {
            assertEquals(buffer[i], byteArrayis.read());
        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.