Package java.nio.channels

Examples of java.nio.channels.ByteChannel


        throw new UnsupportedOperationException();
    }

    public int[] transferBuffer(final long pageOffset, final int aryLength) {
        final int[] dst;
        final ByteChannel channel;
        try {
            channel = openConnection(_sockAddr);
        } catch (IOException ioe) {
            throw new IllegalStateException("failed opening a socket", ioe);
        }
View Full Code Here


        final int pageSize = _pageSize;
        long endPageOffset = (range == null) ? startPageOffset + pageSize : range.getEnd();
        final long lastPageOffset = restrictEndOffset(startPageOffset, endPageOffset, aryLength, pageSize);
        assert (lastPageOffset > startPageOffset) : "Illegal condition.. start:" + startPageOffset
                + " < end:" + lastPageOffset;
        final ByteChannel channel;
        try {
            channel = openConnection(_sockAddr);
        } catch (IOException ioe) {
            throw new IllegalStateException("failed opening a socket", ioe);
        }
View Full Code Here

        }
        return dst;
    }

    public byte[][] readv(final long[] idxs) throws IOException {
        final ByteChannel channel;
        try {
            channel = openConnection(_sockAddr);
        } catch (IOException ioe) {
            throw new IllegalStateException("failed opening a socket", ioe);
        }
View Full Code Here

                session));
    }

    @Override
    protected void destroy(NioSession session) throws Exception {
        ByteChannel ch = session.getChannel();
        SelectionKey key = session.getSelectionKey();
        if (key != null) {
            key.cancel();
        }
        ch.close();
    }
View Full Code Here

        key.interestOps(newInterestOps);
    }

    @Override
    protected int read(NioSession session, IoBuffer buf) throws Exception {
        ByteChannel channel = session.getChannel();
       
        return session.getChannel().read(buf.buf());
    }
View Full Code Here

        session.setSelectionKey(ch.register(selector, SelectionKey.OP_READ, session));
    }

    @Override
    protected void destroy(NioSession session) throws Exception {
        ByteChannel ch = session.getChannel();
        SelectionKey key = session.getSelectionKey();
        if (key != null) {
            key.cancel();
        }
        ch.close();
    }
View Full Code Here

        session.setSelectionKey(ch.register(selector, SelectionKey.OP_READ, session));
    }

    @Override
    protected void destroy(NioSession session) throws Exception {
        ByteChannel ch = session.getChannel();
        SelectionKey key = session.getSelectionKey();
        if (key != null) {
            key.cancel();
        }
        ch.close();
    }
View Full Code Here

                System.exit(1);
            }
           
            Thread.sleep(random.nextInt(50*rate));
           
            ByteChannel channel = new FileInputStream(file).getChannel();
            RandomEndPoint gep = new RandomEndPoint(this,channel);
           
            try
            {
                // TODO in reality this dispatches would be mixed with others from other connections.
View Full Code Here

    public static void main(String[] args) {
        try {
            final SerialPortAPI api = (SerialPortAPI)
                (DeviceUtils.getAPI("serial0", SerialPortAPI.class));
            final ByteChannel channel = api.getChannel(null);

            System.out.println("Writing a test string to the serial port.");
            PrintWriter w = new PrintWriter(new OutputStreamWriter(
                new ChannelOutputStream(channel, 1000)));
            w.print("Hello World!\r\n");
View Full Code Here

        /**
         * Read scancodes from the input channel and dispatch them as events.
         */
        final void processChannel() {
            final ByteBuffer buf = ByteBuffer.allocate(1);
            final ByteChannel channel = getChannel();
            setRunningState(true);
            while ((channel != null) && channel.isOpen() && isRunningState()) {
                try {
                    buf.rewind();
                    if (channel.read(buf) != 1) {
                        continue;
                    }
                    final byte scancode = buf.get(0);
                    E event = handleScancode(scancode);
                    if ((event != null) && !event.isConsumed()) {
View Full Code Here

TOP

Related Classes of java.nio.channels.ByteChannel

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.