List of usage examples for com.google.gwt.dev.util Util copy
public static void copy(InputStream is, OutputStream os) throws IOException
From source file:wetheinter.net.dev.template.TemplateToJava.java
License:Open Source License
private void exportClass(TreeLogger logger, String filename, SourceBuilder<?> context, TemplateGeneratorOptions opts) { File outputFile = new File(opts.getOutputLocation()); // normalize filename if (filename.endsWith(templateSuffix)) filename = filename.substring(0, filename.length() - templateSuffix.length()); if (!filename.endsWith(".java")) filename = filename + ".java"; // repackage if requested; useful for generating non-transient super-source String repackage = context.getRepackage(); if (repackage != null) { filename = repackage.replace('.', File.separatorChar) + File.separator + filename.substring(filename.lastIndexOf('/')); }/*from w ww . ja v a 2 s. c om*/ // save the source to file outputFile = new File(outputFile.getAbsoluteFile(), filename); outputFile.getParentFile().mkdirs(); try { logger.log(Type.INFO, "Writing generated output to " + outputFile.getAbsolutePath()); InputStream in = new ByteArrayInputStream(context.toString().getBytes(utf8)); OutputStream out = new FileOutputStream(outputFile); Util.copy(in, out); } catch (IOException e) { logger.log(Type.ERROR, "Error streaming generated output to file " + outputFile.getAbsolutePath(), e); } }