List of usage examples for java.io Writer close
public abstract void close() throws IOException;
From source file:com.cloudera.oryx.rdf.common.pmml.DecisionForestPMML.java
/** * Writes to a {@link File} instead of {@link Writer}. * * @see #write(Writer, DecisionForest, Map) *//*www .jav a2s. co m*/ public static void write(File pmmlFile, DecisionForest forest, Map<Integer, BiMap<String, Integer>> columnToCategoryNameToIDMapping) throws IOException { Writer pmmlOut = IOUtils.buildGZIPWriter(pmmlFile); try { write(pmmlOut, forest, columnToCategoryNameToIDMapping); } finally { pmmlOut.close(); } }
From source file:net.sourceforge.jcctray.utils.ObjectPersister.java
public static void saveSettings(IJCCTraySettings settings, Writer writer) throws IOException { try {//from w w w. j a v a 2s . c om writer.write("<?xml version='1.0' ?>\n"); writer.write("<cctraysettings>\n"); saveHosts(writer, settings.getHosts()); saveKeyValues(writer, settings.getSettings()); writer.write("</cctraysettings>\n"); } catch (IOException e) { throw e; } finally { writer.close(); } }
From source file:com.deque.axe.AXE.java
/** * Writes a raw object out to a JSON file with the specified name. * @param name Desired filename, sans extension * @param output Object to write. Most useful if you pass in either the Builder.analyze() response or the * violations array it contains. *//*from w ww .ja va 2 s . c o m*/ public static void writeResults(final String name, final Object output) { Writer writer = null; try { writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(name + ".json"), "utf-8")); writer.write(output.toString()); } catch (IOException ignored) { } finally { try { writer.close(); } catch (Exception ignored) { } } }
From source file:org.jboss.as.test.integration.security.loginmodules.common.Utils.java
public static File createTempPropFile(Map<String, String> props) { try {/*from w w w . ja v a 2s. c o m*/ File propsFile = File.createTempFile("props", ".properties"); propsFile.deleteOnExit(); Writer writer = new FileWriter(propsFile); for (Map.Entry<String, String> entry : props.entrySet()) { writer.write(entry.getKey() + "=" + entry.getValue() + "\n"); } writer.close(); return propsFile; } catch (IOException e) { throw new RuntimeException("Temporary file could not be created or writen to!", e); } }
From source file:org.jboss.as.test.integration.security.loginmodules.common.Utils.java
public static void setPropertiesFile(Map<String, String> props, URL propFile) { File userPropsFile = new File(propFile.getFile()); try {/* w w w . j a va2s.co m*/ Writer writer = new FileWriter(userPropsFile); for (Map.Entry<String, String> entry : props.entrySet()) { writer.write(entry.getKey() + "=" + entry.getValue() + "\n"); } writer.close(); } catch (IOException e) { throw new RuntimeException(e); } }
From source file:com.ibm.jaggr.core.test.TestUtils.java
static public File createTestFile(File dir, String name, String content) throws IOException { if (!dir.exists()) dir.mkdirs();//from w ww.java 2 s . c o m String filename = name; if (!filename.contains(".")) filename += ".js"; File f = new File(dir, filename); Writer ow = new FileWriter(f); ow.write(content); ow.close(); return f; }
From source file:com.all.login.services.LoginDatabaseAccess.java
private static void save(File file, LoginDatabase db) { Writer out = null; try {/*from ww w.j a v a 2 s .c om*/ out = new OutputStreamWriter(new FileOutputStream(file)); out.write(JsonConverter.toJson(db)); } catch (Exception e) { LOG.error("Could not serialize LoginDatabase.", e); } finally { try { out.close(); } catch (Exception e) { LOG.error("Could not close LoginDatabase output stream.", e); } } }
From source file:juicebox.tools.utils.juicer.apa.APAUtils.java
public static void saveListText(String filename, List<Double> array) { Writer writer = null; try {//from w ww. j a v a 2s . c o m writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filename), "utf-8")); for (double val : array) { writer.write(val + " "); } writer.write("\n"); } catch (IOException ex) { ex.printStackTrace(); } finally { try { if (writer != null) writer.close(); } catch (Exception ex) { ex.printStackTrace(); } } }
From source file:com.netxforge.oss2.core.xml.CastorUtils.java
/** * Marshall to a string first, then write the string to the file. This * way the original config isn't lost if the xml from the marshall is hosed. * * FIXME: This could still stand to write to a temporary file and/or make a * temporary backup of the production configuration file. * * @param config a {@link java.lang.Object} object. * @param cfgFile a {@link java.io.File} object. * @throws org.exolab.castor.xml.MarshalException if any. * @throws org.exolab.castor.xml.ValidationException if any. * @throws java.io.IOException if any.// ww w . ja v a2 s.co m */ public static void marshalViaString(Object config, File cfgFile) throws MarshalException, ValidationException, IOException { StringWriter stringWriter = new StringWriter(); marshal(config, stringWriter); Writer fileWriter = new OutputStreamWriter(new FileOutputStream(cfgFile), "UTF-8"); fileWriter.write(stringWriter.toString()); fileWriter.flush(); fileWriter.close(); }
From source file:com.portfolio.data.utils.DomUtils.java
public static void saveString(String str, String fileName) throws Exception { // --------------------------------------------------- Writer fwriter = new OutputStreamWriter(new FileOutputStream(fileName), "UTF-8"); fwriter.write(str);/*w ww . j a v a 2s . c om*/ fwriter.close(); }