Java String Unpad unPad(byte[] bytes)

Here you can find the source of unPad(byte[] bytes)

Description

un Pad

License

Open Source License

Declaration

private static byte[] unPad(byte[] bytes) 

Method Source Code

//package com.java2s;
/*//from ww  w. j a v a  2 s .c o  m
 * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
 * or more contributor license agreements. Licensed under the Elastic License;
 * you may not use this file except in compliance with the Elastic License.
 */

public class Main {
    private static byte[] unPad(byte[] bytes) {
        int padded = (int) bytes[bytes.length - 1];
        int targetLength = bytes.length - padded;

        byte[] out = new byte[targetLength];

        System.arraycopy(bytes, 0, out, 0, targetLength);

        return out;
    }
}

Related

  1. unPad(byte[] src, int start, byte[] dest)
  2. unPadLeft(String s, char c)
  3. unPadRight(String s, char c)
  4. unpadZeroString(String string)