This is an old question, and I would just like to add an updated answer, in case someone finds it in a google search. So I would just Stream, Map, toArray.
Set<Integer> s = new HashSet<>();
int[] arr;
s.add(10);
s.add(20);
s.add(30);
arr = s.stream()
.mapToInt(Integer::intValue)
.toArray();