Java how to write to txt file

Java how to write to txt file
re‮l:ot ref‬autturi.com
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.Files;
import java.io.IOException;
import java.nio.file.StandardOpenOption;

/**
 * @author lautturi.com
 * Java example:
 */

import java.util.*;

public class Lautturi {

	public static void main(String[] args) throws IOException {		 
        try
        {
        	String str = "Hello";
        	 
            Path path =  Paths.get("F:/", "temp", "test.txt");
            byte[] strToBytes = str.getBytes();
         
            //Write content to file in java
            Files.write(path, strToBytes);
         
            //Verify file content
            String read = Files.readAllLines(path).get(0);
            System.out.println(read);
            
        } 
        catch (IOException e) 
        {
            e.printStackTrace();
        }

	}
}
Created Time:2017-09-22 11:12:40  Author:lautturi