Here you can find the source of writeLuposBigInteger(final BigInteger value, final int numberOfBits, final OutputStream os)
writeLuposBigInteger.
Parameter | Description |
---|---|
value | a java.math.BigInteger object. |
numberOfBits | a int. |
os | a java.io.OutputStream object. |
Parameter | Description |
---|
public final static void writeLuposBigInteger(final BigInteger value, final int numberOfBits, final OutputStream os) throws IOException
//package com.java2s; import java.io.IOException; import java.io.OutputStream; import java.math.BigInteger; public class Main { /**//w w w. j a v a 2 s . c o m * <p>writeLuposBigInteger.</p> * * @param value a {@link java.math.BigInteger} object. * @param numberOfBits a int. * @param os a {@link java.io.OutputStream} object. * @throws java.io.IOException if any. */ public final static void writeLuposBigInteger(final BigInteger value, final int numberOfBits, final OutputStream os) throws IOException { int remainingBits = numberOfBits; BigInteger remainingValue = value; final BigInteger BYTE = BigInteger.valueOf(256); while (remainingBits > 0) { final BigInteger[] result = remainingValue .divideAndRemainder(BYTE); remainingValue = result[0]; os.write((byte) result[1].intValue()); remainingBits -= 8; } } }