/** * Copy the contents of the given String to the given output OutputStream. * Leaves the stream open when done. * @param in the String to copy from * @param charset the Charset * @param out the OutputStream to copy to * @throws IOException in case of I/O errors */ public static void copy(String in, Charset charset, OutputStream out) throws IOException { Assert.notNull(in, "No input String specified"); Assert.notNull(charset, "No charset specified"); Assert.notNull(out, "No OutputStream specified"); Writer writer = new OutputStreamWriter(out, charset); writer.write(in); writer.flush(); }
public void writeLineToInfoFile(String line) { if (infoPath == null || line == null || line.length() == 0) { return; } try { checkWriter(); infoWrite.write(line); infoWrite.write("\n"); infoWrite.flush(); } catch (Exception e) { throw new RuntimeException("write info file error, infoPath:" + infoPath + " content:" + line, e); } }
@Override public void run() { try { fileToEdit.getParentFile().mkdirs(); FileOutputStream fos=new FileOutputStream(fileToEdit); Writer w=new BufferedWriter(new OutputStreamWriter(fos)); try { w.write(text); w.flush(); fos.getFD().sync(); } finally { w.close(); } } catch (IOException e) { Log.e(getClass().getSimpleName(), "Exception writing file", e); } } }
/** * Copies reader to output stream using buffer and specified encoding. */ public static void copy(Reader input, OutputStream output, String encoding) throws IOException { Writer out = new OutputStreamWriter(output, encoding); copy(input, out); out.flush(); } /**
private void writeIndex(File indexFile) { try { FileUtils.forceMkdir(indexFile.getParentFile()); try (Writer writer = new OutputStreamWriter(new FileOutputStream(indexFile), StandardCharsets.UTF_8)) { for (InstalledPlugin plugin : pluginFs.getInstalledFiles()) { writer.append(toRow(plugin)); writer.append(CharUtils.LF); } writer.flush(); } } catch (IOException e) { throw new IllegalStateException("Unable to generate plugin index at " + indexFile, e); } }
public void process(OutputStream out) throws IOException { Writer w = new OutputStreamWriter(out, charset); w.append(c); w.flush(); w.close(); } });
final Writer w = new BufferedWriter( new OutputStreamWriter( baos, "UTF-8" ) ); final XMLWriter xw = new XMLWriter( w, new OutputFormat( " ", true ) ); xw.write( document ); w.flush();
@Override public void run() { try { fileToEdit.getParentFile().mkdirs(); FileOutputStream fos=new FileOutputStream(fileToEdit); Writer w=new BufferedWriter(new OutputStreamWriter(fos)); try { w.write(text); w.flush(); fos.getFD().sync(); } finally { w.close(); } } catch (IOException e) { Log.e(getClass().getSimpleName(), "Exception writing file", e); } } }
/** * Tell the server to exit */ public void sendQuit() throws IOException { Socket socket = new Socket(host, port); Writer out = new OutputStreamWriter(socket.getOutputStream(), "utf-8"); out.write("quit\n"); out.flush(); socket.close(); }
/** * Copies specified number of characters from reader to output stream using buffer and specified encoding. */ public static void copy(Reader input, OutputStream output, String encoding, int charCount) throws IOException { Writer out = new OutputStreamWriter(output, encoding); copy(input, out, charCount); out.flush(); }
private void doSaveJarDecompiled(File inFile, File outFile) throws Exception { try (JarFile jfile = new JarFile(inFile); FileOutputStream dest = new FileOutputStream(outFile); BufferedOutputStream buffDest = new BufferedOutputStream(dest); ZipOutputStream out = new ZipOutputStream(buffDest);) { throw new Exception("Unable to resolve type."); Writer writer = isUnicodeEnabled ? new OutputStreamWriter(out, "UTF-8") : new OutputStreamWriter(out); PlainTextOutput plainTextOutput = new PlainTextOutput(writer); plainTextOutput.setUnicodeOutputEnabled(isUnicodeEnabled); settings.getLanguage().decompileType(resolvedType, plainTextOutput, decompilationOptions); writer.flush(); } catch (Exception e) { label.setText("Cannot decompile file: " + entry.getName());
public void process(OutputStream out) throws IOException { Writer w = new OutputStreamWriter(out, charset); w.append(c); w.flush(); w.close(); } });
@Override public BenchmarkResultHook addResults(Map<String, Long> results) { requireNonNull(results, "results is null"); try { Joiner.on(",").withKeyValueSeparator(":").appendTo(writer, results); writer.write('\n'); writer.flush(); } catch (IOException e) { throw new UncheckedIOException(e); } return this; }
public void writeToOutputStream(Object model, OutputStream out) throws Exception { Writer writer = new BufferedWriter(new OutputStreamWriter(new OutputStreamWrapper(out), UTF8)); writeToWriter(model, writer); writer.flush(); }
@Override public void run() { try { fileToEdit.getParentFile().mkdirs(); FileOutputStream fos=new FileOutputStream(fileToEdit); Writer w=new BufferedWriter(new OutputStreamWriter(fos)); try { w.write(text); w.flush(); fos.getFD().sync(); } finally { w.close(); } } catch (IOException e) { Log.e(getClass().getSimpleName(), "Exception writing file", e); } } }
/** * Copy the contents of the given String to the given output OutputStream. * Leaves the stream open when done. * @param in the String to copy from * @param charset the Charset * @param out the OutputStream to copy to * @throws IOException in case of I/O errors */ public static void copy(String in, Charset charset, OutputStream out) throws IOException { Writer writer = new OutputStreamWriter(out, charset); writer.write(in); writer.flush(); }