Created
April 8, 2011 16:22
-
-
Save aslakknutsen/910210 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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