Class TemporaryFiles
- java.lang.Object
-
- net.officefloor.server.http.stream.TemporaryFiles
-
public class TemporaryFiles extends java.lang.Object
Provides means to manage temporaryFileChannel
content.- Author:
- Daniel Sagenschneider
-
-
Constructor Summary
Constructors Constructor Description TemporaryFiles(java.lang.String prefix)
Instantiate and creates the temporary files area.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.nio.channels.FileChannel
createTempFile(java.lang.String name, byte[] contents)
Creates aFileChannel
to a temporary file.java.nio.channels.FileChannel
createTempFile(java.lang.String name, byte[] contents, int offset, int length)
Creates aFileChannel
to a temporary file.java.nio.channels.FileChannel
createTempFile(java.lang.String name, java.io.InputStream contents)
Creates aFileChannel
to the temporary file.java.nio.channels.FileChannel
createTempFile(java.lang.String name, java.lang.String contents)
Creates aFileChannel
to the temporary file using the default HTTP entityCharset
.java.nio.channels.FileChannel
createTempFile(java.lang.String name, java.lang.String contents, java.nio.charset.Charset charset)
Creates aFileChannel
to the temporary file.static TemporaryFiles
getDefault()
Obtains the defaultTemporaryFiles
.
-
-
-
Method Detail
-
getDefault
public static TemporaryFiles getDefault() throws java.io.IOException
Obtains the defaultTemporaryFiles
.- Returns:
- Default
TemporaryFiles
. - Throws:
java.io.IOException
- If fails to create the defaultTemporaryFiles
.
-
createTempFile
public java.nio.channels.FileChannel createTempFile(java.lang.String name, java.io.InputStream contents) throws java.io.IOException
Creates aFileChannel
to the temporary file.- Parameters:
name
- Name to aid identifying the temporary file on disk. May benull
.contents
-InputStream
to contents for the temporary file.- Returns:
FileChannel
to the temporary file.- Throws:
java.io.IOException
- If fails to create temporary file.
-
createTempFile
public java.nio.channels.FileChannel createTempFile(java.lang.String name, byte[] contents, int offset, int length) throws java.io.IOException
Creates aFileChannel
to a temporary file.- Parameters:
name
- Name to aid identifying the temporary file on disk. May benull
.contents
- Contents for the temporary file.offset
- Offset into contents.length
- Length from offset to write to file.- Returns:
FileChannel
to the temporary file.- Throws:
java.io.IOException
- If fails to create temporary file.
-
createTempFile
public java.nio.channels.FileChannel createTempFile(java.lang.String name, byte[] contents) throws java.io.IOException
Creates aFileChannel
to a temporary file.- Parameters:
name
- Name to aid identifying the temporary file on disk. May benull
.contents
- Contents for the temporary file.- Returns:
FileChannel
to the temporary file.- Throws:
java.io.IOException
- If fails to create temporary file.
-
createTempFile
public java.nio.channels.FileChannel createTempFile(java.lang.String name, java.lang.String contents, java.nio.charset.Charset charset) throws java.io.IOException
Creates aFileChannel
to the temporary file.- Parameters:
name
- Name to aid identifying the temporary file on disk. May benull
.contents
- Contents for the temporary file.charset
-Charset
to write the contents. May benull
to use default HTTP entityCharset
.- Returns:
FileChannel
to the temporary file.- Throws:
java.io.IOException
- If fails to create temporary file.
-
createTempFile
public java.nio.channels.FileChannel createTempFile(java.lang.String name, java.lang.String contents) throws java.io.IOException
Creates aFileChannel
to the temporary file using the default HTTP entityCharset
.- Parameters:
name
- Name to aid identifying the temporary file on disk. May benull
.contents
- Contents for the temporary file.- Returns:
FileChannel
to the temporary file.- Throws:
java.io.IOException
- If fails to create temporary file.
-
-