private File writeStrintToFile(String s) throws IOException { File tmpFile = File.createTempFile("temp", ".txt"); System.out.println(tmpFile.getPath()); UTF8Writer writer = new UTF8Writer(tmpFile); for (char c : s.toCharArray()) { writer.write(c); } // To simulate texteditor, which writes LN end of every file. writer.write(0x0a); writer.flush(); writer.close(); return tmpFile; }