plenty of methods for copying to array in HERE - in fact you have to create new array with size+1, as usual arrays have fixed size. some example method:
static <T> T[] append(T[] arr, T element) {
final int N = arr.length;
arr = Arrays.copyOf(arr, N + 1);
arr[N] = element;
return arr;
}
your call
append(info, data1);
BUT I must aware you that this isn't well-perfomance way, it would be better to use ArrayList
for info
instead of not-so-efficient and fixed size array. copying whole array to new one with size N + 1
(and additional item) is in fact heavy operation and you want to use it in while
method...
if you would have
private ArrayList<String> info = new ArrayList<>();
then you can simply call add
inside while
safely
info.add(data1);