Java String Sub String substr(byte[] i_Value, int i_BeginIndex)

Here you can find the source of substr(byte[] i_Value, int i_BeginIndex)

Description

substr

License

Open Source License

Declaration

public static byte[] substr(byte[] i_Value, int i_BeginIndex) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {

    public static byte[] substr(byte[] i_Value, int i_BeginIndex) {
        return substr(i_Value, i_BeginIndex, i_Value.length - i_BeginIndex);
    }//w w  w.j  a  v  a  2 s.c  o m

    public static byte[] substr(byte[] i_Value, int i_BeginIndex, int i_SubLen) {
        int v_BeginIndex = i_BeginIndex % i_Value.length;
        int v_EndIndex = v_BeginIndex + i_SubLen;
        int v_NewArrLen = v_EndIndex <= i_Value.length ? i_SubLen : i_Value.length - v_BeginIndex - 1;
        v_EndIndex = v_BeginIndex + v_NewArrLen;
        byte[] v_Ret = new byte[v_NewArrLen];

        for (int v_Index = v_BeginIndex; v_Index < v_EndIndex; v_Index++) {
            v_Ret[v_Index - v_BeginIndex] = i_Value[v_Index];
        }

        return v_Ret;
    }
}

Related

  1. substr(String s, int start, int end)
  2. substr(String s, String sub, boolean before)
  3. substr(String src, int beginIndex, int endIndex)
  4. subStr(String src, int len)