Java examples for File Path IO:File Operation
Writing to a simple file
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) throws IOException { Path newPath = Paths.get("/home/docs/newUsers.txt"); byte[] newContents = "Christopher".getBytes(); Files.write(newPath, newContents, StandardOpenOption.CREATE); Files.write(newPath, newContents, StandardOpenOption.APPEND); }/*from w w w .j av a2 s. c om*/ }