Here you can find the source of appendLineInFile(String path, String lines)
Parameter | Description |
---|---|
path | of the file to open |
lines | to append |
public static void appendLineInFile(String path, String lines)
//package com.java2s; //License from project: Open Source License import java.io.DataOutputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; public class Main { /**/* w w w .j a va 2s .co m*/ * * @param path of the file to open * @param lines to append */ public static void appendLineInFile(String path, String lines) { FileOutputStream fouts; try { fouts = new FileOutputStream(path, true); DataOutputStream douts = new DataOutputStream(fouts); douts.writeBytes(lines.toString()); douts.flush(); douts.close(); fouts.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }