If you want to write a simple text file, would be better if you use a BufferedWriter. For your content, you can format it in a StringBuffer or a StringBuilder if it is too long. Here in this post, I replied to a question related with the kind of formatting you're trying to make. But you should need to adapt it according to your format and the logic of using a wrapping array.
Export array values to csv file java
I think, the loop or "enhanced for" statement should be used as something like:
for (ArrayList<String> innerArray: wrapperArray) {
for (String word : innerArray) {
//Adapt to your required format using a StringBuilder
}
}
//Here at the end save the content of your StringBuilder or StringBuffer using the BufferedWriter.
Hope you can get an idea on how to achieve this. Best regards :)