public void read(SelectionKey key) throws IOException {

        System.out.println("READ CLIENT: ");
        //ByteBuffer buf = ByteBuffer.allocateDirect(StringConstants.BUF_SIZE);
        MappedByteBuffer buf = null;

        SocketChannel socketChannel	= (SocketChannel)key.channel();
        RandomAccessFile fromFile = new RandomAccessFile(destination + "/" + currentFile.getName() + "X", "rw");
        FileChannel fc = fromFile.getChannel();
        long bytesReaded;
        int progress = 0;
        int count = 0;
        long fileSize = 1;

        logger.info("Client: Started getting data ...");

        buf = fc.map(FileChannel.MapMode.READ_WRITE, count, StringConstants.BUF_SIZE);
        while ((bytesReaded = socketChannel.read(buf)) > 0){

            count += bytesReaded;
            
            buf.flip();
            buf = fc.map(FileChannel.MapMode.READ_WRITE, count, bytesReaded);
            if (progress > 100)
                setProgress(100);
            else setProgress(progress);

            progress += Math.ceil((bytesReaded * 100)/fileSize) + 1;
            buf.clear();
        }

        setProgress(100);
        buf.clear();
        fc.close();
        fromFile.close();
        socketChannel.close();
        key.cancel();
        logger.info("Client: Finished getting data ...");
        System.out.println("done");

    }