Package org.apache.juneau.marshall.swaps
Class InputStreamSwap
java.lang.Object
org.apache.juneau.marshall.swap.spi.ObjectSwap<T,String>
org.apache.juneau.marshall.swap.spi.StringSwap<InputStream>
org.apache.juneau.marshall.swaps.InputStreamSwap
- Direct Known Subclasses:
InputStreamSwap.Base64,InputStreamSwap.Hex,InputStreamSwap.SpacedHex
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classConvertsInputStreamsto BASE-64 encoding.static classConvertsInputStreamsto hex encoding.static classConvertsInputStreamsto spaced-hex encoding. -
Field Summary
Fields inherited from class org.apache.juneau.marshall.swap.spi.ObjectSwap
NULL -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected byte[]toBytes(InputStream is) Convert the specified input stream to a byte array.protected InputStreamConvert the specified byte array into an input stream.Methods inherited from class org.apache.juneau.marshall.swap.spi.ObjectSwap
forMediaTypes, forMediaTypes, getNormalClass, getSwapClass, getSwapClassMeta, isNormalObject, isSwappedObject, match, swap, swap, toString, unswap, unswap, withTemplate, withTemplate
-
Constructor Details
-
InputStreamSwap
public InputStreamSwap()
-
-
Method Details
-
toBytes
Convert the specified input stream to a byte array.- Parameters:
is- The input stream to convert to bytes.
Can benull (returns an empty array).
The stream is automatically closed.- Returns:
- The byte array.
- Throws:
IOException- Thrown by input stream.
-
toStream
Convert the specified byte array into an input stream.- Parameters:
b- The byte array.hint- Contains a hint about what subtype is being requested.
Can benull , in which caseInputStreamis assumed.- Returns:
- The contents of the byte array as an input stream, or
null if the hint requests a stream subtype other thanInputStreamorByteArrayInputStream.
-