How to create temporary and get the absolute path in Java

1 Answer

0 votes
package javaapplication1;

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

public class JavaApplication1 {

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

        try {

            File file = File.createTempFile("tmp", ".txt");

            System.out.println(file.getAbsolutePath());

        } catch (Exception e) {
            System.out.print(e);
        }
    }
}


/*
        
run:
  
C:\Users\Avi\AppData\Local\Temp\tmp5732333622839232902.txt
    
 */

 



answered Nov 16, 2016 by avibootz

Related questions

3 answers 288 views
2 answers 223 views
1 answer 201 views
1 answer 223 views
2 answers 184 views
184 views asked Dec 1, 2023 by avibootz
1 answer 174 views
...