Sunday, 11 June 2017

Java Tutorial : Java IO (Java File - How to create the temporary file) ~ foundjava


Click here to watch in Youtube :

FileDemo.java
import java.io.File;
import java.io.IOException;

public class FileDemo
{

    public static void main(String[] args) throws IOException
    {
        File tempFile = File.createTempFile("temp", ".txt");

        /*
         * Will give you the full complete path name
         * (filepath + filename) of a file.
         */
        String absolutePath = tempFile.getAbsolutePath();
        System.out.println("File path : " + absolutePath);

    }

}
Output
File path : C:\Users\Ramesh\AppData\Local\Temp\temp5613613809025056166.txt

Click the below link to download the code:

CLICK HERE

No comments:

Post a Comment