PrintWriter failing to print to file

You have to flush and / or close the file to get the data written to the disk.

Add out.close() in your code:

PrintWriter out = new PrintWriter(file);
for (int y=0; y<arr.length; y++){
    out.println(arr[y]);
}
out.close()

Leave a Comment