Java Files write byte array to a file to append
import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardOpenOption; public class Main { public static void main(String[] args) { Path path = Paths.get("Main.java"); try {/*from w ww. j a v a 2s .c om*/ byte[] contents = "demo2s.com".getBytes(); Files.write(path, contents, StandardOpenOption.APPEND); } catch (IOException e) { e.printStackTrace(); } } }