Here you can find the source of lengthToWrite(final byte[] data, final int offset, final int dataLength, final boolean rightTrim)
lengthToWrite.
Parameter | Description |
---|---|
data | an array of byte. |
offset | a int. |
dataLength | a int. |
rightTrim | a boolean. |
public static int lengthToWrite(final byte[] data, final int offset, final int dataLength, final boolean rightTrim)
//package com.java2s; //License from project: Open Source License public class Main { /**// w w w . j a va 2s .c om * <p> * lengthToWrite. * </p> * * @param data an array of byte. * @param offset a int. * @param dataLength a int. * @param rightTrim a boolean. * @return a int. */ public static int lengthToWrite(final byte[] data, final int offset, final int dataLength, final boolean rightTrim) { int lengthToWrite = 0; if (!rightTrim) lengthToWrite = dataLength; else for (int i = offset + dataLength - 1; i >= offset; i--) if (data[i] != ' ') { lengthToWrite = (i - offset) + 1; break; } return lengthToWrite; } }