Package org.jgroups.util

Examples of org.jgroups.util.ByteArrayDataInputStream.position()


        assert in.position() == 0;
        assert in.limit() == buf.length;
        assert in.capacity() == buf.length;

        in=new ByteArrayDataInputStream(buf, 0, 4);
        assert in.position() == 0;
        assert in.limit() == 4;
        assert in.capacity() == buf.length;
        byte tmp[]=new byte[4];
        in.read(tmp, 0, tmp.length);
        assert "Bela".equals(new String(tmp));
View Full Code Here


    public void testOffsetAndLimit() {
        byte[] buf=new byte[100];
        buf[10]='B'; buf[11]='e'; buf[12]='l'; buf[13]='a';
        ByteArrayDataInputStream in=new ByteArrayDataInputStream(buf, 10, 4);
        assert in.position() == 10;
        assert in.limit() == 14;
        assert in.capacity() == buf.length;
        byte tmp[]=new byte[4];
        in.read(tmp, 0, tmp.length);
        assert "Bela".equals(new String(tmp));
View Full Code Here

    public void testReadBeyondLimit() {
        byte[] buf=new byte[100];
        buf[10]='B'; buf[11]='e'; buf[12]='l'; buf[13]='a';
        ByteArrayDataInputStream in=new ByteArrayDataInputStream(buf, 10, 4);
        assert in.position() == 10;
        assert in.limit() == 14;
        assert in.capacity() == buf.length;
        byte tmp[]=new byte[5];
        try {
            in.readFully(tmp, 0, tmp.length);
View Full Code Here

        catch(Exception ex) {
            System.out.println("caught exception as expected: " + ex);
            assert ex instanceof EOFException;
        }

        in.position(10);
        for(int i=0; i < 4; i++) in.read();
        assert in.read() == -1;
    }

View Full Code Here

    public void testPosition() {
        byte[] buf=new byte[100];
        buf[10]='B'; buf[11]='e'; buf[12]='l'; buf[13]='a';
        ByteArrayDataInputStream in=new ByteArrayDataInputStream(buf, 10, 4);
        in.position(13);
        try {
            in.position(14);
        }
        catch(Exception ex) {
            System.out.println("caught exception as expected: " + ex);
View Full Code Here

        byte[] buf=new byte[100];
        buf[10]='B'; buf[11]='e'; buf[12]='l'; buf[13]='a';
        ByteArrayDataInputStream in=new ByteArrayDataInputStream(buf, 10, 4);
        in.position(13);
        try {
            in.position(14);
        }
        catch(Exception ex) {
            System.out.println("caught exception as expected: " + ex);
            assert ex instanceof IndexOutOfBoundsException;
        }
View Full Code Here

    }

    public void testSkipBytes() {
        byte[] buf={'h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd'};
        ByteArrayDataInputStream in=new ByteArrayDataInputStream(buf);
        assert in.position() == 0;
        int skipped=in.skipBytes(6);
        assert skipped == 6;
        assert in.position() == 6;

        skipped=in.skipBytes(0);
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.