com.ning.http.multipart
Class ByteArrayPartSource

java.lang.Object
  extended by com.ning.http.multipart.ByteArrayPartSource
All Implemented Interfaces:
PartSource

public class ByteArrayPartSource
extends Object
implements PartSource

This class is an adaptation of the Apache HttpClient implementation


Constructor Summary
ByteArrayPartSource(String fileName, byte[] bytes)
          Constructor for ByteArrayPartSource.
 
Method Summary
 InputStream createInputStream()
          Gets a new InputStream for reading this source.
 String getFileName()
          Gets the name of the file this source represents.
 long getLength()
          Gets the number of bytes contained in this source.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ByteArrayPartSource

public ByteArrayPartSource(String fileName,
                           byte[] bytes)
Constructor for ByteArrayPartSource.

Parameters:
fileName - the name of the file these bytes represent
bytes - the content of this part
Method Detail

getLength

public long getLength()
Description copied from interface: PartSource
Gets the number of bytes contained in this source.

Specified by:
getLength in interface PartSource
Returns:
a value >= 0
See Also:
PartSource.getLength()

getFileName

public String getFileName()
Description copied from interface: PartSource
Gets the name of the file this source represents.

Specified by:
getFileName in interface PartSource
Returns:
the fileName used for posting a MultiPart file part
See Also:
PartSource.getFileName()

createInputStream

public InputStream createInputStream()
                              throws IOException
Description copied from interface: PartSource
Gets 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:
createInputStream in interface PartSource
Returns:
a new InputStream
Throws:
IOException - if an error occurs when creating the InputStream
See Also:
PartSource.createInputStream()


Copyright © 2011. All Rights Reserved.