I don't see a conversion to an array of integers necessary, since you're just using modes. This also handles the case of having multiple modes (like "0 1 1 0 3" will give [0,1])
Java:
public static List<Integer> modes(String line)
{
if(line == null || line == "") throw new...