Skip to content

Instantly share code, notes, and snippets.

@narkisr
Created July 16, 2009 20:25
Show Gist options
  • Save narkisr/148668 to your computer and use it in GitHub Desktop.
Save narkisr/148668 to your computer and use it in GitHub Desktop.
public <T> String toAmf(final T source) throws IOException {
final StringBuffer buffer = new StringBuffer();
final ByteArrayOutputStream bout = new ByteArrayOutputStream();
final Provider<SerializationContext> provider = new SerializationContextProvider();// creating the provider
final Amf3Output amf3Output = new Amf3Output(provider.get());// creating the context instance
amf3Output.setOutputStream(bout);
amf3Output.writeObject(source);
amf3Output.flush();
amf3Output.close();
final BASE64Encoder encoder = new BASE64Encoder();
return encoder.encode(bout.toByteArray());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment