Here you can find the source of arrayFillNonAtomic(byte bArray[], short bOff, short bLen, byte bValue)
Parameter | Description |
---|---|
bArray | the byte array |
bOff | offset within byte array to start filling bValue into |
bLen | byte length to be filled |
bValue | the value to fill the byte array with |
Parameter | Description |
---|---|
ArrayIndexOutOfBoundsException | if the fill operation would cause access of data outside array bounds |
NullPointerException | if bArray is <code>null</code> |
public static final short arrayFillNonAtomic(byte bArray[], short bOff, short bLen, byte bValue) throws ArrayIndexOutOfBoundsException, NullPointerException
//package com.java2s; /*/* www.j a va 2s .c o m*/ * Copyright 2011 Licel LLC. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ public class Main { /** * Fills the byte array (non-atomically) beginning at the specified position, * for the specified length with the specified byte value. * <p>This method does not use the transaction facility during the fill operation even if * a transaction is in progress. Thus, this * method is suitable for use only when the contents of the byte array can be left in * a partially filled state in the event of a power loss in the middle of the fill operation. * <p> * Note:<ul> * <li><em>If </em><code>bOff</code><em> or </em><code>bLen</code><em> parameter * is negative an </em><code>ArrayIndexOutOfBoundsException</code><em> exception is thrown.</em> * <li><em>If </em><code>bOff+bLen</code><em> is greater than </em><code>bArray.length</code><em>, the length * of the </em><code>bArray</code><em> array an </em><code>ArrayIndexOutOfBoundsException</code><em> exception is thrown.</em> * <li><em>If </em><code>bArray</code><em> parameter is </em><code>null</code><em> * a </em><code>NullPointerException</code><em> exception is thrown.</em> * <li><em>If power is lost during the copy operation and the byte array is persistent, * a partially changed byte array could result.</em> * <li><em>The </em><code>bLen</code><em> parameter is not constrained by the atomic commit capacity limitations.</em></ul> * @param bArray the byte array * @param bOff offset within byte array to start filling bValue into * @param bLen byte length to be filled * @param bValue the value to fill the byte array with * @return bOff+bLen * @throws ArrayIndexOutOfBoundsException if the fill operation would cause access of data outside array bounds * @throws NullPointerException if bArray is <code>null</code> * @see JCSystem.getUnusedCommitCapacity() */ public static final short arrayFillNonAtomic(byte bArray[], short bOff, short bLen, byte bValue) throws ArrayIndexOutOfBoundsException, NullPointerException { byte tester = bArray[bOff]; if (bLen < 0) { throw new ArrayIndexOutOfBoundsException(); } while (bLen-- > 0) { bArray[bOff++] = bValue; } return (short) (bOff + bLen); } }