List of usage examples for java.util Arrays copyOf
public static boolean[] copyOf(boolean[] original, int newLength)
From source file:Main.java
/** * Return a String List representing response from invokeOemRilRequestRaw * * @param aob byte array response from invokeOemRilRequestRaw *//*w ww. j a v a 2 s.c o m*/ public static List<String> unpackListOfStrings(byte aob[]) { if (aob.length == 0) { Log.v(TAG, "Length = 0"); return Collections.emptyList(); } int lines = aob.length / CHARS_PER_LINE; String[] display = new String[lines]; for (int i = 0; i < lines; i++) { int offset, byteCount; offset = i * CHARS_PER_LINE + 2; byteCount = 0; if (offset + byteCount >= aob.length) { Log.e(TAG, "Unexpected EOF"); break; } while (aob[offset + byteCount] != 0 && (byteCount < CHARS_PER_LINE)) { byteCount += 1; if (offset + byteCount >= aob.length) { Log.e(TAG, "Unexpected EOF"); break; } } display[i] = new String(aob, offset, byteCount).trim(); } int newLength = display.length; while (newLength > 0 && TextUtils.isEmpty(display[newLength - 1])) { newLength -= 1; } return Arrays.asList(Arrays.copyOf(display, newLength)); }
From source file:in.mtap.iincube.mongoser.codec.crypto.Psyfer.java
public static Psyfer getInstance(String secretKey) throws NoSuchAlgorithmException, UnsupportedEncodingException, NoSuchPaddingException, InvalidKeyException { MessageDigest digest = MessageDigest.getInstance("SHA-1"); byte[] key = digest.digest(secretKey.getBytes("UTF-8")); key = Arrays.copyOf(key, 16); SecretKeySpec secretKeySpec = new SecretKeySpec(key, "AES"); Cipher eCipher = Cipher.getInstance("AES"); Cipher deCipher = Cipher.getInstance("AES"); eCipher.init(Cipher.ENCRYPT_MODE, secretKeySpec); deCipher.init(Cipher.DECRYPT_MODE, secretKeySpec); return new Psyfer(eCipher, deCipher); }
From source file:Main.java
/** * Return a String List representing response from invokeOemRilRequestRaw * * @param aob Byte array response from invokeOemRilRequestRaw *///from w w w. ja v a 2 s. c o m public static List<String> unpackByteListOfStrings(byte aob[]) { if (aob.length == 0) { Log.v(TAG, "Length = 0"); return Collections.emptyList(); } int lines = aob.length / CHARS_PER_LINE; String[] display = new String[lines]; for (int i = 0; i < lines; i++) { int offset, byteCount; offset = i * CHARS_PER_LINE + 2; byteCount = 0; if (offset + byteCount >= aob.length) { Log.e(TAG, "Unexpected EOF"); break; } while (aob[offset + byteCount] != 0 && (byteCount < CHARS_PER_LINE)) { byteCount += 1; if (offset + byteCount >= aob.length) { Log.e(TAG, "Unexpected EOF"); break; } } display[i] = new String(aob, offset, byteCount).trim(); } int newLength = display.length; while (newLength > 0 && TextUtils.isEmpty(display[newLength - 1])) { newLength -= 1; } return Arrays.asList(Arrays.copyOf(display, newLength)); }
From source file:io.servicecomb.foundation.vertx.http.TestStandardHttpServletRequestEx.java
@Test public void setBodyBuffer() { Buffer bodyBuffer = Buffer.buffer(); bodyBuffer.appendString("abc"); System.out.println(bodyBuffer.length()); requestEx.setBodyBuffer(bodyBuffer); Assert.assertSame(bodyBuffer, requestEx.getBodyBuffer()); Assert.assertArrayEquals("abc".getBytes(), Arrays.copyOf(requestEx.getBodyBytes(), requestEx.getBodyBytesLength())); }
From source file:hivemall.utils.lang.ArrayUtils.java
@Nonnull public static <T> T[] set(@Nonnull T[] src, final int index, final T value) { if (index >= src.length) { src = Arrays.copyOf(src, src.length * 2); }//from w w w .jav a2 s . c o m src[index] = value; return src; }
From source file:com.offbynull.voip.kademlia.externalmessages.FindResponse.java
/** * Constructs a {@link FindResponse} object. * @param nodes closest nodes to the ID that was searched for * @throws NullPointerException if any argument is {@code null} or contains {@code null} *//*from w w w. ja va 2 s . c o m*/ public FindResponse(Node[] nodes) { Validate.notNull(nodes); Validate.noNullElements(nodes); this.nodes = Arrays.copyOf(nodes, nodes.length); }
From source file:de.hybris.platform.webservices.util.objectgraphtransformer.impl.DefaultNodeConfig.java
public DefaultNodeConfig(final NodeConfig template) { super();//from w w w. j a v a 2 s. c o m this.type = template.getType(); if (template.getUidProperties() != null) { this.uidProperties = Arrays.copyOf(template.getUidProperties(), template.getUidProperties().length); } }
From source file:com.offbynull.voip.audio.gateways.io.internalmessages.InputPcmBlock.java
/** * Get PCM data. * @return PCM data */ public byte[] getData() { return Arrays.copyOf(data, data.length); }
From source file:com.bytecode.util.Crypto.java
private static byte[] decrypt(String keystring, byte[] message, int bits) throws Exception { byte[] decValue = null; byte[] nonceBytes = Arrays.copyOf(Arrays.copyOf(message, 8), 16); IvParameterSpec nonce = new IvParameterSpec(nonceBytes); Key key = generateKey(keystring, bits); Cipher c = Cipher.getInstance(ALGORITHM); c.init(Cipher.DECRYPT_MODE, key, nonce); decValue = c.doFinal(message, 8, message.length - 8); return decValue; }
From source file:com.intuit.tank.search.util.MultiSearchParam.java
/** * /*from w w w .j a v a 2s.c om*/ * @param operator * the operator to specify * @param params * must be at least one param */ public MultiSearchParam(Operator operator, SearchParam... params) { this.operator = operator; this.params = Arrays.copyOf(params, params.length); assert params.length != 0; }