Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;

public class Main {

    public static void main(String[] args) throws Exception {

        Path rootDirectory = FileSystems.getDefault().getPath("C:/home/docs");

        Path tempDirectory = Files.createTempDirectory(rootDirectory, "");
        System.out.println("Temporary directory created successfully!");
        String dirPath = tempDirectory.toString();
        System.out.println(dirPath);
        Path tempFile = Files.createTempFile(tempDirectory, "", "");
        System.out.println("Temporary file created successfully!");
        String filePath = tempFile.toString();
        System.out.println(filePath);
    }
}