public class StreamSerializer
extends java.lang.Object
Constructor and Description |
---|
StreamSerializer() |
Modifier and Type | Method and Description |
---|---|
ItemStack |
deserializeItemStack(java.io.DataInputStream input)
Read or deserialize an item stack from an underlying input stream.
|
ItemStack |
deserializeItemStack(java.lang.String input)
Deserialize an item stack from a base-64 encoded string.
|
void |
serializeItemStack(java.io.DataOutputStream output,
ItemStack stack)
Write or serialize an item stack to the given output stream.
|
java.lang.String |
serializeItemStack(ItemStack stack)
Serialize an item stack as a base-64 encoded string.
|
public ItemStack deserializeItemStack(@Nonnull java.io.DataInputStream input) throws java.io.IOException
To supply a byte array, wrap it in a ByteArrayInputStream
and DataInputStream
.
input
- - the target input stream.java.io.IOException
- If the operation failed due to reflection or corrupt data.public ItemStack deserializeItemStack(@Nonnull java.lang.String input) throws java.io.IOException
input
- - base-64 encoded string.java.io.IOException
- If the operation failed due to reflection or corrupt data.public void serializeItemStack(@Nonnull java.io.DataOutputStream output, ItemStack stack) throws java.io.IOException
To supply a byte array, wrap it in a ByteArrayOutputStream
and DataOutputStream
.
Note: An ItemStack can be written to a stream even if it's NULL.
output
- - the target output stream.stack
- - the item stack that will be written, or NULL to represent air/nothing.java.io.IOException
- If the operation fails due to reflection problems.public java.lang.String serializeItemStack(ItemStack stack) throws java.io.IOException
Note: An ItemStack can be written to the serialized text even if it's NULL.
stack
- - the item stack to serialize, or NULL to represent air/nothing.java.io.IOException
- If the operation fails due to reflection problems.