public class TempFile
extends java.lang.Object
| Constructor and Description |
|---|
TempFile(java.io.File dir,
java.lang.String prefix,
java.lang.String suffix)
Creates a temporary file on the file system.
|
TempFile(java.lang.String prefix,
java.lang.String suffix)
Creates a temporary file on the file system.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
checkReleased()
Ensures that this instance has not been released.
|
java.io.File |
getFile()
Returns the temporary file.
|
java.io.InputStream |
getInputStream()
Returns an
InputStream that can be used to read the content of
the temp file. |
java.io.InputStream |
getInputStream(boolean deleteOnClose)
Returns an
InputStream that can be used to read the content of
the temp file. |
java.io.OutputStream |
getOutputStream()
Calling this method, is same as doing:
|
java.io.OutputStream |
getOutputStream(boolean buffered)
Creates an outputstream that can be used to write data into the
underlying temporary file.
|
void |
release()
Delete the temporary file from the local file system.
|
public TempFile(java.lang.String prefix,
java.lang.String suffix)
throws java.io.IOException
java.lang.IllegalArgumentException - If the prefix argument contains fewer
than three charactersjava.io.IOException - If a file could not be createdFile.createTempFile(String,String,File)public TempFile(java.io.File dir,
java.lang.String prefix,
java.lang.String suffix)
throws java.io.IOException
java.lang.IllegalArgumentException - If the prefix argument contains fewer
than three charactersjava.io.IOException - If a file could not be createdFile.createTempFile(String,String,File)public java.io.OutputStream getOutputStream()
throws java.io.IOException
return getOutputStream(false);
java.io.IOExceptiongetOutputStream(boolean)public java.io.OutputStream getOutputStream(boolean buffered)
throws java.io.IOException
buffered - True if to create a buffered output streamjava.io.IOException - If unable to create the output stream due to IO
errorspublic java.io.File getFile()
java.lang.IllegalStateException - If this instance has been released.protected void checkReleased()
IllegalStateException will be thrown.java.lang.IllegalStateException - If this instance has been released.public void release()
public java.io.InputStream getInputStream()
throws java.io.IOException
InputStream that can be used to read the content of
the temp file.
This method does getInputStream(false);
InputStream for reading the content of the temp file.java.io.IOExceptiongetInputStream(boolean)public java.io.InputStream getInputStream(boolean deleteOnClose)
throws java.io.IOException
InputStream that can be used to read the content of
the temp file.
If the deleteOnClose argument is true, the temp file is deleted
when the close method is called on the
InputStream.
deleteOnClose - Defines if the temp file should be deleted upon
closing the input stream.InputStream for reading the content of the temp file.java.io.IOExceptionCopyright ? Technia AB. All Rights Reserved.