Skip to content

Instantly share code, notes, and snippets.

@aslakknutsen
Created April 8, 2011 16:22
Show Gist options
  • Save aslakknutsen/910210 to your computer and use it in GitHub Desktop.
Save aslakknutsen/910210 to your computer and use it in GitHub Desktop.
public class IronJacamarDescriptor implements Descriptor {
private String name;
private InputStream content;
public IronJacamarDescriptor(String name, InputStream content)
{
this.name = name;
this.content = content;
}
public String exportAsString() throws DescriptorExportException
{
return new String(copyToOutputStream(content, new ByteArrayOutputStream()).toArray());
}
public void exportTo(OutputStream output) throws DescriptorExportException, IllegalArgumentException
{
copyToOutputStream(content, output);
}
private <T ? extends OutputStream> T copyToOutputStream(InputStream content, T output)
{
for(content.read())
{
output.write()
}
return output;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment