KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I stole this snippet off the web. But it looks to be limited to 4096 bytes and is quite ugly IMO. Anyone know of a better approach? I'm actually using Groovy btw... String streamToString(InputStream input) { StringBuffer out = new StringBuffer(); byte[] b = new byte[4096]; for (int n; (n = input.read(b)) != -1;) { out.append(new String(b, 0, n)); } return out.toString(); } EDIT: I found a better solution in Groovy: InputStream exportTemplateStream = getClass().getClassLoader().getResourceAsStream("export.template") assert exportTemplateStream: "[export.template stream] resource not found" String exportTemplate = exportTemplateStream.text
Tags (comma-separated)
Save Edits
Cancel