Package com.fizzed.crux.util
Class TemporaryPath
- java.lang.Object
-
- com.fizzed.crux.util.TemporaryPath
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class TemporaryPath extends java.lang.Object implements java.io.CloseableWhen you are opening a path with try-with-resources that you want to be deleted on close.
-
-
Constructor Summary
Constructors Constructor Description TemporaryPath(java.nio.file.Path file)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()java.nio.file.PathgetPath()voidsafeClose()Closes (deletes) the temporary file and suppresses any IO exception that may or may not occur.static TemporaryPathtempDirectory()static TemporaryPathtempDirectory(java.lang.String prefix)static TemporaryPathtempDirectory(java.nio.file.Path baseDir)static TemporaryPathtempDirectory(java.nio.file.Path baseDir, java.lang.String prefix)static TemporaryPathtempFile()static TemporaryPathtempFile(java.lang.String prefix)static TemporaryPathtempFile(java.lang.String prefix, java.lang.String suffix)static TemporaryPathtempFile(java.nio.file.Path baseDir)static TemporaryPathtempFile(java.nio.file.Path baseDir, java.lang.String prefix)static TemporaryPathtempFile(java.nio.file.Path baseDir, java.lang.String prefix, java.lang.String suffix)java.lang.StringtoString()
-
-
-
Method Detail
-
getPath
public java.nio.file.Path getPath()
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
safeClose
public void safeClose()
Closes (deletes) the temporary file and suppresses any IO exception that may or may not occur.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
tempFile
public static TemporaryPath tempFile()
-
tempFile
public static TemporaryPath tempFile(java.nio.file.Path baseDir)
-
tempFile
public static TemporaryPath tempFile(java.lang.String prefix)
-
tempFile
public static TemporaryPath tempFile(java.nio.file.Path baseDir, java.lang.String prefix)
-
tempFile
public static TemporaryPath tempFile(java.lang.String prefix, java.lang.String suffix)
-
tempFile
public static TemporaryPath tempFile(java.nio.file.Path baseDir, java.lang.String prefix, java.lang.String suffix)
-
tempDirectory
public static TemporaryPath tempDirectory()
-
tempDirectory
public static TemporaryPath tempDirectory(java.nio.file.Path baseDir)
-
tempDirectory
public static TemporaryPath tempDirectory(java.lang.String prefix)
-
tempDirectory
public static TemporaryPath tempDirectory(java.nio.file.Path baseDir, java.lang.String prefix)
-
-