fix
Helius
2021-08-05 8bbb027dc36b3f3c7f2d505fc75180261fb4d640
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package com.xzx.gc.util;
 
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
 
/**
 * 数据格式转化类
 * @author xiandafu
 *
 */
public class ConvertUtil {
    /**
     * 转化逗号分隔的id到long数组,通常用于批量操作
     * @param str
     * @return
     */
    public static List<Long> str2longs(String str){
        if(str.length()==0){
            return Collections.EMPTY_LIST;
        }
        String[] array = str.split(",");
        List<Long> rets = new ArrayList(array.length);
        int i = 0;
        for(String id:array){
            try{
                rets.add(Long.parseLong(id));
            }catch(Exception ex){
                throw new RuntimeException("转化 "+str+ " 到Long数组出错");
            }
            
        }
        return rets;
    }
}