If you're using Java 8+, the Stream API makes for a very fluent alternative to the for loop construct:
int[] n = ...;
final int limit = 68;
System.out.println(""); // start on a new line
Arrays.stream(n)
.mapToObj(i -> ((Integer) i).toString()) // convert ints to strings
.forEach(s -> {
int i = 0;
while(i < s.length) {
System.out.print(s.substring(i, i + limit));
System.out.println(i + limit < s.length ? "\\" : "");
i += limit;
}
});
Alternatively, you could do something similar with a for loop if you're on an older Java version:
int[] n = ...;
final int limit = 68;
System.out.println(""); // start on a new line
for (int i = 0; i < n.length; i++) {
String s = Integer.toString(n[i]);
int i = 0;
while(i < s.length) {
System.out.print(s.substring(i, i + limit));
System.out.println(i + limit < s.length ? "\\" : "");
i += limit;
}
}
Either way, you just need to first convert the integer to a string, and then print only the substring up to 68 characters in length at a time. System.out.print prints output without adding a new line at the end.