Java Code Examples for org.apache.commons.lang.StringUtils.splitByWholeSeparator()

The following are Jave code examples for showing how to use splitByWholeSeparator() of the org.apache.commons.lang.StringUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: kaltura-ce-sakai-extension   File: MediaItem.java   Source Code and License Vote up 5 votes
public String[] getTags() {
    String[] tags = new String[0];
    if (kalturaItem != null && kalturaItem.tags != null) {
        tags = StringUtils.splitByWholeSeparator(kalturaItem.tags, ", ");
    }
    return tags;
}
 
Example 2
Project: util4j   File: HexStrBytes.java   Source Code and License Vote up 5 votes
/**
 * 根据字节数组拆分若干个字字节数组
 * @param data    待拆分数组
 * @param separator 分割数组
 * @return 
 */
public byte[][] getSonArrays(byte[] data,byte[] separator)
{
	if(data==null||data.length<=0||separator==null||separator.length<=0)
	{
		System.out.println("data||separator数据无效!");
		return null;
	}
	String[] dataHexArray=toHexArray(data);
	String dataHexStr=StringUtils.substringBetween(Arrays.toString(dataHexArray), "[", "]").replaceAll("\\s","");
	//System.out.println("待拆分字符串:"+dataHexStr);
	String[] separatorHexhArray=toHexArray(separator);
	String separatorHexStr=StringUtils.substringBetween(Arrays.toString(separatorHexhArray), "[", "]").replaceAll("\\s","");
	//System.out.println("字符串拆分符:"+separatorHexStr);
	//得到拆分后的数组
	String[] arrays=StringUtils.splitByWholeSeparator(dataHexStr, separatorHexStr);
	//System.out.println("拆分后的数组:"+Arrays.toString(arrays));
	if(arrays==null||arrays.length<=0)
	{
		System.out.println("注意:数组拆分为0");
		return null;
	}
	byte[][] result=new byte[arrays.length][];
	//对子数组进行重组
	for(int i=0;i<arrays.length;i++)
	{
		String arrayStr=arrays[i];
		arrayStr=StringUtils.removeStart(arrayStr, ",");//去掉两端的逗号
		arrayStr=StringUtils.removeEnd(arrayStr, ",");//去掉两端的逗号
		String[] array=arrayStr.split(",");//根据子字符串中间剩余的逗号重组为hex字符串
		result[i]=toBtyeArray(array);
	}
	return result;
}
 
Example 3
Project: util4j   File: DataTools.java   Source Code and License Vote up 5 votes
/**
 * 根据字节数组拆分若干个字字节数组
 * @param data
 * @param separator
 * @return
 */
public byte[][] getsonArrays(byte[] data,byte[] separator)
{
	if(data==null||data.length<=0||separator==null||separator.length<=0)
	{
		System.out.println("data||separator数据无效!");
		return null;
	}
	String[] dataHexArray=byteArrayToHexArray(data);
	String dataHexStr=StringUtils.substringBetween(Arrays.toString(dataHexArray), "[", "]").replaceAll("\\s","");
	//System.out.println("待拆分字符串:"+dataHexStr);
	String[] separatorHexhArray=byteArrayToHexArray(separator);
	String separatorHexStr=StringUtils.substringBetween(Arrays.toString(separatorHexhArray), "[", "]").replaceAll("\\s","");
	//System.out.println("字符串拆分符:"+separatorHexStr);
	//得到拆分后的数组
	String[] arrays=StringUtils.splitByWholeSeparator(dataHexStr, separatorHexStr);
	//System.out.println("拆分后的数组:"+Arrays.toString(arrays));
	if(arrays==null||arrays.length<=0)
	{
		System.out.println("注意:数组拆分为0");
		return null;
	}
	byte[][] result=new byte[arrays.length][];
	//对子数组进行重组
	for(int i=0;i<arrays.length;i++)
	{
		String arrayStr=arrays[i];
		arrayStr=StringUtils.removeStart(arrayStr, ",");//去掉两端的逗号
		arrayStr=StringUtils.removeEnd(arrayStr, ",");//去掉两端的逗号
		String[] array=arrayStr.split(",");//根据子字符串中间剩余的逗号重组为hex字符串
		result[i]=hexArrayToBtyeArray(array);
	}
	return result;
}