Java tutorial
//package com.java2s; import java.io.FileOutputStream; public class Main { public synchronized static void writeCh(String path, String cmd) { try { cmd = cmd + "\n"; FileOutputStream out = new FileOutputStream(path, true); out.write(cmd.getBytes()); out.close(); } catch (Exception e) { e.printStackTrace(); } } }