public void write(final long address, final byte[] data) throws Exception {

        if (blockCount == -1) {
            throw new IllegalStateException("You first have to open the Device!");
        }

        long blocks = data.length / blockSize;

        if (address < 0 || address + blocks > blockCount) {
            long adr;
            if (address < 0) {
                adr = address;
            } else {
                adr = address + blocks - 1;
            }
            throw new IllegalArgumentException("Address " + adr + " out of range.");
        }

        if (data.length % blockSize != 0) {
            throw new IllegalArgumentException("Number of bytes is not a multiple of the blocksize!");
        }

        final ByteBuffer src = ByteBuffer.wrap(data);
        initiator.write(target, src, (int)address, data.length);
    }
public void write ( final long address , final byte [ ] data ) throws Exception { if ( blockCount == - 1 ) { throw new IllegalStateException ( "You first have to open the Device!" ) ; } long blocks = data . length / blockSize ; if ( address < 0 || address + blocks > blockCount ) { long adr ; if ( address < 0 ) { adr = address ; } else { adr = address + blocks - 1 ; } throw new IllegalArgumentException ( "Address " + adr + " out of range." ) ; } if ( data . length % blockSize != 0 ) { throw new IllegalArgumentException ( "Number of bytes is not a multiple of the blocksize!" ) ; } final ByteBuffer src = ByteBuffer . wrap ( data ) ; initiator . write ( target , src , ( int ) address , data . length ) ; }
{@inheritDoc}