Java Temp Directory Get getTempDirectory()

Here you can find the source of getTempDirectory()

Description

Returns the absolute path of a temp directory.

License

Apache License

Declaration

public static String getTempDirectory() throws IOException 

Method Source Code


//package com.java2s;
// Licensed under the Apache License, Version 2.0 (the "License");

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

public class Main {
    /**/*from ww w.java 2 s.com*/
     * Returns the absolute path of a temp directory. The directory is *not* created.
     */
    public static String getTempDirectory() throws IOException {
        final File temp = File.createTempFile("temp", Long.toString(System.nanoTime()));
        if (!(temp.delete())) {
            throw new IOException("Could not delete temp file: " + temp.getAbsolutePath());
        }
        return temp.getAbsolutePath();
    }
}

Related

  1. getTempDirectory()
  2. getTempDirectory()
  3. getTempDirectory()
  4. getTempDirectory()
  5. getTempDirectory()
  6. getTempDirectory()
  7. getTempDirectory()
  8. getTempDirectory()
  9. getTempDirectory()