Java tutorial
//package com.java2s; //License from project: Apache License import java.io.BufferedWriter; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; public class Main { public static void saveAllScripts(String projectName, String fileName, String content) throws FileNotFoundException { fileName = fileName.substring(1, fileName.length()); String path = System.getProperty("user.dir") + "/workspace/" + projectName.substring(0, projectName.indexOf(System.getProperty("file.separator"))) + "/Scripts/" + fileName; writeFile(path, content, false); } public static void writeFile(String path, String content, boolean append) throws FileNotFoundException { //File file = new File(path); FileOutputStream writerStream = new FileOutputStream(path, append); BufferedWriter writer = null; try { writer = new BufferedWriter(new OutputStreamWriter(writerStream, "UTF-8")); writer.write(content); writer.flush(); writer.close(); } catch (IOException e) { e.printStackTrace(); } finally { if (writer != null) { try { writer.close(); } catch (IOException e1) { } } } } }