Java 8 BufferedWriter - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 BufferedWriter class.

This code example shows how to use the following methods:close, write
		return fileContents.toString();
	} 
 
	public void write(String filePath, String content) throws IOException {
		File file = new File(filePath);
		BufferedWriter writer = new BufferedWriter(new FileWriter(file, true));
		writer.write(content);
		writer.close();
	} 
 
	public BufferedReader getReader() {
		String storageMode = getStorageMode();
		String synchMode = getSynchMode();
		BufferedReader reader = null;
 
		try { 
			if (storageMode.equals("sdcard") || synchMode.equals("sdcard")) {
				File root = Environment.getExternalStorageDirectory();
				File morgDir = new File(root, "mobileorg");
				File morgFile = new File(morgDir, fileName);
8
CodeRank
This code example shows how to use the following methods:close, write
        FrameGroupCommandQueueSet.getQueueSet(sessionId);
 
    if (queueSet.getExtensionJs().length() > 0) {
      String path = "scripts/user-extensions.js[" + sessionId + "]";
      FileWriter fileWriter = new FileWriter(new File(coreDir, path));
      BufferedWriter writer = new BufferedWriter(fileWriter);
 
      writer.write(queueSet.getExtensionJs());
      writer.close();
 
      fileWriter.close();
    } 
  } 
 
  public void close() { 
    if (browserOptions.is("killProcessesByName")) {
      WindowsUtils.tryToKillByName("iexplore.exe"); 
    } 
    if (browserOptions.is("killProcessesByName")) {
      WindowsUtils.tryToKillByName("mshta.exe"); 
8
CodeRank
This code example shows how to use the following methods:write
            unicode = true;
        } 
    } 
 
    public void startDocument(String encoding, Boolean standalone) throws IOException {
        writer.write("<?xml version='1.0' ");
 
        if (encoding != null) {
            this.encoding = encoding;
            if (encoding.toLowerCase(Locale.US).startsWith("utf")) {
                unicode = true;
            } 
        } 
 
        if (this.encoding != null) {
            writer.write("encoding='");
            writer.write(this.encoding);
            writer.write("' ");
        } 
 

8
CodeRank
This code example shows how to use the following methods:flush, write
        return true; 
    } 
 
    public void writeTo(Object arg0, Class<?> arg1, Type arg2, Annotation[] arg3, MediaType arg4,
            MultivaluedMap<String, Object> arg5, OutputStream arg6) throws IOException, WebApplicationException {
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(arg6));
        bw.write(arg0.toString());
        bw.flush();
    } 
} 
9
CodeRank
This code example shows how to use the following methods:close, flush
public class CsvView extends AbstractView { 
 
    @Override 
    protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception {
        response.setHeader("Content-Disposition","attachment; filename=\"" + (String)model.get("key") + "_" + (String)model.get("key") + ".csv\"");
        BufferedWriter writer = new BufferedWriter(response.getWriter());
         
        //myDbData = (Whatever) modelMap.get("modelKey"); 
        //some kind of loop {writer.write(myDbData csv row); writer.newLine(); } 
        writer.flush();
        writer.close();
    } 
} 
8
CodeRank
This code example shows how to use the following methods:close, flush, newLine, write
        try { 
            socket = new Socket();
            socket.connect(new InetSocketAddress("127.0.0.1",
                    DeviceBridge.getDeviceLocalPort(device)));
 
            out = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
 
            out.write(command + " " + window.encode() + " " + params);
            out.newLine();
            out.flush();
        } catch (IOException e) {
            // Empty 
        } finally { 
            try { 
                if (out != null) {
                    out.close();
                } 
                if (socket != null) {
                    socket.close();
                } 
            } catch (IOException ex) {
7
CodeRank
This code example shows how to use the following methods:
    private String mProcessName = null;
 
    public MediaTestUtil(String memoryOutFileName, String testName, String processName)
            throws Exception { 
        File memoryOut = new File(memoryOutFileName);
        mOutput = new BufferedWriter(new FileWriter(memoryOut, true));
        mProcessName = processName;
        mTestName = testName;
        mStartPid = getPid();
        mStartMemory = getVsize();
    } 
 
    // Catpure the heapdump for memory leaksage analysis 
    public static void getNativeHeapDump(String name) throws Exception {
        System.gc();
        System.runFinalization();
        Thread.sleep(1000);
        FileOutputStream o = new FileOutputStream(STORAGE_PATH + '/' + name + ".dump");
        Debug.dumpNativeHeap(o.getFD());
        o.close();
8
CodeRank
This code example shows how to use the following methods:close, flush, write
        return n; 
    } 
 
    private static File writeFile(File f, String str) throws IOException { 
        f.getParentFile().mkdirs(); 
        BufferedWriter fout = new BufferedWriter(new FileWriter(f)); 
        try { 
            fout.write(str); 
            fout.flush(); 
        } finally { 
            fout.close(); 
        } 
        return f; 
    } 
} 
7
CodeRank
This code example shows how to use the following methods:close, write
		return fileContents.toString();
	} 
 
	public void write(String filePath, String content) throws IOException {
		File file = new File(filePath);
		BufferedWriter writer = new BufferedWriter(new FileWriter(file, true));
		writer.write(content);
		writer.close();
	} 
 
	public BufferedReader getReader() {
		String storageMode = getStorageMode();
		String synchMode = getSynchMode();
		BufferedReader reader = null;
 
		try { 
			if (storageMode.equals("sdcard") || synchMode.equals("sdcard")) {
				File root = Environment.getExternalStorageDirectory();
				File morgDir = new File(root, "mobileorg");
				File morgFile = new File(morgDir, fileName);
7
CodeRank
This code example shows how to use the following methods:flush, write
	} 
 
	public static <T extends JSONParcelable> void writeObject(final OutputStream stream, final T parcelable)
			throws IOException {
		if (stream == null || parcelable == null) return;
		final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(stream, Charset.defaultCharset()));
		final JSONObject json = new JSONObject();
		try { 
			json.put(KEY_CLASS, parcelable.getClass().getName());
			json.put(KEY_OBJECT, toJSONObject(parcelable));
			writer.write(jsonToString(json));
			writer.flush();
		} catch (final JSONException e) {
			throw new IOException(e);
		} finally { 
			Utils.closeSilently(writer);
		} 
	} 
 
	@SuppressWarnings("unchecked") 
	private static <T extends JSONParcelable> JSONParcelable.Creator<T> getCreator(final String name)
7
CodeRank

Related Java 8 BufferedWriter Questions & Answers:

See Code Examples for Java 8 BufferedWriter Methods: