Class ByteArrayPartSource
- java.lang.Object
-
- org.apache.commons.httpclient.methods.multipart.ByteArrayPartSource
-
- All Implemented Interfaces:
PartSource
public class ByteArrayPartSource extends java.lang.Object implements PartSource
A PartSource that reads from a byte array. This class should be used when the data to post is already loaded into memory.- Since:
- 2.0
-
-
Constructor Summary
Constructors Constructor Description ByteArrayPartSource(java.lang.String fileName, byte[] bytes)Constructor for ByteArrayPartSource.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.io.InputStreamcreateInputStream()Gets a new InputStream for reading this source.java.lang.StringgetFileName()Gets the name of the file this source represents.longgetLength()Gets the number of bytes contained in this source.
-
-
-
Method Detail
-
getLength
public long getLength()
Description copied from interface:PartSourceGets the number of bytes contained in this source.- Specified by:
getLengthin interfacePartSource- Returns:
- a value >= 0
- See Also:
PartSource.getLength()
-
getFileName
public java.lang.String getFileName()
Description copied from interface:PartSourceGets the name of the file this source represents.- Specified by:
getFileNamein interfacePartSource- Returns:
- the fileName used for posting a MultiPart file part
- See Also:
PartSource.getFileName()
-
createInputStream
public java.io.InputStream createInputStream() throws java.io.IOExceptionDescription copied from interface:PartSourceGets a new InputStream for reading this source. This method can be called more than once and should therefore return a new stream every time.- Specified by:
createInputStreamin interfacePartSource- Returns:
- a new InputStream
- Throws:
java.io.IOException- if an error occurs when creating the InputStream- See Also:
PartSource.createInputStream()
-
-