PrintWriter pw = new PrintWriter("testOutput.txt"); String[] strs = { "hello", "world", "", "circus" }; for(int j = 0; j < strs.length; j++) { if(!strs[j].equals("")) pw.println(strs[j]); } pw.close();