Java tutorial
//package com.java2s; import java.io.BufferedWriter; import java.io.File; import java.io.FileOutputStream; import java.io.OutputStreamWriter; public class Main { public static void generateFile(String str) throws Exception { File target = new File(System.getProperty("user.dir") + "/src/sql1.txt"); FileOutputStream fos = new FileOutputStream(target); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos, "utf-8")); bw.write(str.toString()); bw.close(); } }