package com.ucarhu.demo.util;

public class TransTool {
    public static int[] splitStringWithSpaceToIntArray(String str) {
        if (str == null) {
            return null;
        }
        String[] split = str.split(" ");
        int[] iArr = new int[split.length];
        for (int i = 0; i < split.length; i++) {
            try {
                iArr[i] = Integer.parseInt(split[i]);
            } catch (NumberFormatException unused) {
                return null;
            }
        }
        return iArr;
    }

    public static String joinIntArrayWithSpace(int[] iArr) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < iArr.length; i++) {
            sb.append(iArr[i]);
            if (i < iArr.length - 1) {
                sb.append(" ");
            }
        }
        return sb.toString();
    }
}
