Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
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 rn_demo = Paths.get("C:/tutorial/Java", "demo.txt");
        String demo = "tutorial";
        String string = "\nString: from java2s.com";

        //using NIO.2 unbuffered stream
        byte data[] = demo.getBytes();
        try (OutputStream outputStream = Files.newOutputStream(rn_demo)) {
            outputStream.write(data);
        } catch (IOException e) {
            System.err.println(e);
        }

    }
}