Sorry i misread.
extra note:
from hardwired:
if(!strs[j].trim().equals(""))
pw.println(strs[j]);
if you add the trim(), you are making sure that if the string array has a space element (so " ") it will not be put in the file.
Also, String.length() yields better performance.