Android Byte Array Cut deleteMark(byte[] b)

Here you can find the source of deleteMark(byte[] b)

Description

delete Mark

Declaration

public static void deleteMark(byte[] b) 

Method Source Code

//package com.java2s;

public class Main {

    public static void deleteMark(byte[] b) {
        int len = b.length;
        if ((len & 1) == 1) {
            b[len - 1] = '\0';
            len--;//from   w w w .jav a  2 s  .com
        }
        int count = 0;
        for (int i = 0; i < len; i += 2) {
            int high = b[i] & 0xff;
            int low = b[i + 1] & 0xff;
            if (high == '\0' || low == '\0') {
                count = count + len - i;
                break;
            } else if (high == 0x21
                    && (low == 0x26 || low == 0x3e || low == 0x47 || low == 0x5d)) {
                count += 2;
            } else {
                b[i - count] = (byte) high;
                b[i - count + 1] = (byte) low;
            }
        }
        if (count > 0) {
            int size = b.length;
            for (int i = len - count; i < size; i++) {
                b[i] = '\0';
            }
        }
    }
}

Related

  1. cutBytes(byte[] bytes, int pos, int length)
  2. deleteSpace(byte[] b)
  3. deleteSpaceLatin(byte[] b)
  4. remove(byte[] data, int place)