Util.java 796 Bytes

public class Util {
	public static long[][] getArraysFromImport(String str){
		long[][] arrays = new long[4][];
		String[] split = str.split("\n");
		if(split.length < 4)
			return null;
		
		for(int i=0; i<arrays.length; i++) {
			arrays[i] = getArrayFromLine(split[i], i);
			if(arrays[i] == null)
				return null;
		}
		return arrays;
	}
	private static long[] getArrayFromLine(String str, int nLine) {
		str = str.substring(1, str.length() - 2); // remove { and }
		String[] longsStr;
		if(nLine <= 1)
			longsStr = str.split(", ");
		else
			longsStr = str.split("L, ");
		
		try {
			long[] longs = new long[longsStr.length];
			for(int i=0; i<longs.length; i++)
				longs[i] = Long.parseLong(longsStr[i]);
			return longs;
		} catch (NumberFormatException ignored) {}
		return null;
	}
}