List of usage examples for java.io BufferedWriter write
public void write(int c) throws IOException
From source file:hudson.plugins.chainreactorclient.ChainReactorInvalidServerException.java
protected void sendBuildInfo(BufferedWriter writer) throws IOException { writer.write(this.json); writer.flush();/* w w w . ja v a 2 s. c o m*/ }
From source file:de.Keyle.MyPet.util.configuration.ConfigurationJSON.java
public boolean save() { try {// w w w.j a v a 2s .c o m // http://jsonformatter.curiousconcept.com/ BufferedWriter writer = new BufferedWriter(new FileWriter(jsonFile)); writer.write(config.toJSONString()); writer.close(); return true; } catch (IOException e) { e.printStackTrace(); DebugLogger.printThrowable(e); return false; } }
From source file:org.openmrs.logic.rule.definition.JavaLanguageHandler.java
/** * @see CompilableLanguageHandler#prepareSource(RuleDefinition,String) */// w w w .j a va2s .co m public void prepareSource(RuleDefinition logicRule, String className) { AdministrationService as = Context.getAdministrationService(); String javaDirectory = as.getGlobalProperty(LogicConstants.RULE_DEFAULT_SOURCE_FOLDER); File sourceDirectory = OpenmrsUtil.getDirectoryInApplicationDataDirectory(javaDirectory); String path = className.replace('.', File.separatorChar); File javaFile = new File(sourceDirectory, path + JAVA_EXTENSION); if (!javaFile.getParentFile().exists()) javaFile.getParentFile().mkdirs(); Date modifiedDate = logicRule.getDateChanged(); if (modifiedDate == null) { modifiedDate = logicRule.getDateCreated(); } // only compile when the java file is not exist or the concept derived is updated after the source file last modified if (!javaFile.exists() || modifiedDate.after(new Date(javaFile.lastModified()))) { String content = logicRule.getRuleContent(); content = content.replace("{CLASSNAME}", className.substring(className.lastIndexOf('.') + 1)); try { BufferedWriter writer = new BufferedWriter(new FileWriter(javaFile)); writer.write(content); writer.close(); } catch (IOException e) { log.error("Failed saving java rule file ...", e); } } }
From source file:hsa.awp.common.dao.template.TemplateFileSystemDao.java
@Override public void saveTemplate(String content, TemplateDetail templateDetail) { try {/*from w w w . j av a 2 s .c o m*/ File file = new File(generatePath(templateDetail)); BufferedWriter out = new BufferedWriter(new FileWriter(file)); out.write(content); out.close(); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.maxl.java.aips2xml.Aips2Xml.java
static void writeToFile(String string_to_write, String dir_name, String file_name) { try {/* w w w . j ava 2 s.c o m*/ File wdir = new File(dir_name); if (!wdir.exists()) wdir.mkdirs(); File wfile = new File(dir_name + file_name); if (!wfile.exists()) wfile.createNewFile(); // FileWriter fw = new FileWriter(wfile.getAbsoluteFile()); CharsetEncoder encoder = Charset.forName("UTF-8").newEncoder(); encoder.onMalformedInput(CodingErrorAction.REPORT); encoder.onUnmappableCharacter(CodingErrorAction.REPORT); OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(wfile.getAbsoluteFile()), encoder); BufferedWriter bw = new BufferedWriter(osw); bw.write(string_to_write); bw.close(); } catch (IOException e) { e.printStackTrace(); } }
From source file:de.akquinet.dustjs.DustEngine.java
public void compile(File input, File output) { try {//from www .j a v a2 s .co m String content = compile(input); if (!output.exists()) { output.createNewFile(); } BufferedWriter bw = new BufferedWriter(new FileWriter(output)); bw.write(content); bw.close(); } catch (IOException e) { logger.error(e.getMessage()); } }
From source file:com.depas.utils.FileUtils.java
public static void writeArrayToFile(String fileName, String[] contents, boolean utfEncoding) throws IOException { BufferedWriter out = null; try {/*from ww w . ja v a2 s. c o m*/ File outFile = new File(fileName); OutputStreamWriter osw; if (utfEncoding) { osw = new OutputStreamWriter(new FileOutputStream(outFile), "UTF-8"); } else { osw = new OutputStreamWriter(new FileOutputStream(outFile)); } out = new BufferedWriter(osw); for (int i = 0; i < contents.length; i++) { out.write(contents[i]); out.newLine(); } out.close(); out = null; } finally { if (out != null) { out.close(); } } }