Question

I have a problem with method .each(int bufferSize, Closure closure).

new FileInputStream(fname).eachByte(4) { buffer ->
    def x = new BigInteger(buffer);
    println x;
}

And similar here:

new File(fname).eachByte(4) { buffer -> 
    def x = new BigInteger(buffer);
    println x;
}

So, i get a

groovy.lang.MissingMethodException: No signature of method: $_readBitSeq_closure2.doCall() is applicable for argument types: ([B, java.lang.Integer) values: [[60, 110, -13, 95], 4]

Anybody know how to solve this problem???

Thanks, Oleg.

Était-ce utile?

La solution

The eachByte( int ) method requires a 2 parameter Closure

The first parameter is the byte buffer, the second parameter is the number of bytes that were read from the Stream. Try:

new FileInputStream(fname).eachByte(4) { buffer, nReads ->
    def x = new BigInteger(buffer);
    println x;
}

The same is true for File.eachByte( int )

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top