public static String read(Reader in) throws IOException { StringWriter buffer = new StringWriter(); copy(in, buffer); return buffer.toString(); }
public static String read(Reader in) throws IOException { StringWriter buffer = new StringWriter(); copy(in, buffer); return buffer.toString(); }
public static void write(byte[] content, File f) throws IOException { FileOutputStream out = new FileOutputStream(f); try { copy(new ByteArrayInputStream(content), out); } finally { safeClose(out); } }
public static String read(InputStream in, Charset charset) throws IOException { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); copy(in, baos); return new String(baos.toByteArray(), charset); } finally { safeClose(in); } }
public static void write(byte[] content, File f) throws IOException { FileOutputStream out = new FileOutputStream(f); try { copy(new ByteArrayInputStream(content), out); } finally { safeClose(out); } }
public static byte[] bytes(InputStream in) throws IOException { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(in.available()); copy(in, baos); return baos.toByteArray(); } finally { safeClose(in); } }
public static byte[] bytes(InputStream in) throws IOException { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(in.available()); copy(in, baos); return baos.toByteArray(); } finally { safeClose(in); } }
public static String read(InputStream in, Charset charset) throws IOException { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); copy(in, baos); return new String(baos.toByteArray(), charset); } finally { safeClose(in); } }
@Override public long updateResource(File file, Resource resource) throws IOException { File parent = file.getParentFile(); if (parent != null) { if (!parent.exists()) { if (!parent.mkdirs()) { throw new IOException("Could not create parent directory " + parent.getCanonicalPath()); } } } InputStream in = resource.getInputStream(); FileOutputStream out = new FileOutputStream(file); try { Tools.copy(in, out); } finally { Tools.safeClose(out); } return file.lastModified(); }
@Override public long updateResource(File file, Resource resource) throws IOException { File parent = file.getParentFile(); if (parent != null) { if (!parent.exists()) { if (!parent.mkdirs()) { throw new IOException("Could not create parent directory " + parent.getCanonicalPath()); } } } InputStream in = resource.getInputStream(); FileOutputStream out = new FileOutputStream(file); try { Tools.copy(in, out); } finally { Tools.safeClose(out); } return file.lastModified(); }
buffer.append(adapter.substring(0, idx)).append("\n"); Tools.copy(new NormalizeJSReader(new InputStreamReader(stream)), buffer); if (idx != -1) { buffer.append(adapter.substring(idx + "@{include}".length(), adapter.length()));
resp.setContentType(contentType); Tools.copy(in, resp.getOutputStream());
buffer.append(adapter.substring(0, idx)).append("\n"); Tools.copy(new NormalizeJSReader(new InputStreamReader(stream)), buffer); if (idx != -1) { buffer.append(adapter.substring(idx + "@{include}".length(), adapter.length()));
resp.setContentType(contentType); Tools.copy(in, resp.getOutputStream());
append(cs.value); } else if (data instanceof Chunk.Data.InputStream) { ByteArrayOutputStream baos = Tools.copy(((Chunk.Data.InputStream)data).data, new ByteArrayOutputStream()); append(baos.toByteArray()); } else if (data instanceof Chunk.Data.Readable) {
append(cs.value); } else if (data instanceof Chunk.Data.InputStream) { ByteArrayOutputStream baos = Tools.copy(((Chunk.Data.InputStream)data).data, new ByteArrayOutputStream()); append(baos.toByteArray()); } else if (data instanceof Chunk.Data.Readable) {
Tools.safeClose(Tools.copy(new StringReader("#{include path=foo.gtmpl}#{/include}"), new FileWriter(index))); assertTrue(index.setLastModified(index.lastModified() + 1000)); Tools.safeClose(Tools.copy(new StringReader("#{include path=bar.gtmpl}#{/include}"), new FileWriter(foo))); assertTrue(foo.setLastModified(index.lastModified() + 1000));
Tools.safeClose(Tools.copy(new StringReader("#{include path=foo.gtmpl}#{/include}"), new FileWriter(index))); assertTrue(index.setLastModified(index.lastModified() + 1000)); Tools.safeClose(Tools.copy(new StringReader("#{include path=bar.gtmpl}#{/include}"), new FileWriter(foo))); assertTrue(foo.setLastModified(index.lastModified() + 1000));
@Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { if (count++ == 0) { try { ProcessingContext ctx = new ProcessingContext(processingEnv); ElementHandle.Package pkg = ElementHandle.Package.create(ctx.getPackageElement("compiler.dot.foo")); FileObject file = ctx.resolveResourceFromSourcePath(pkg, FileKey.newName("compiler.dot.foo", "a.b.txt")); InputStream in = file.openInputStream(); FileObject o = ctx.createResource(StandardLocation.CLASS_OUTPUT, FileKey.newName("compiler.dot.foo", "a.b.css")); OutputStream out = o.openOutputStream(); Tools.copy(in, out); Tools.safeClose(in); Tools.safeClose(out); } catch (Exception e) { throw failure(e); } } return true; } });
@Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { if (count++ == 0) { try { ProcessingContext ctx = new ProcessingContext(processingEnv); ElementHandle.Package pkg = ElementHandle.Package.create(ctx.getPackageElement("compiler.dot.foo")); FileObject file = ctx.resolveResourceFromSourcePath(pkg, FileKey.newName("compiler.dot.foo", "a.b.txt")); InputStream in = file.openInputStream(); FileObject o = ctx.createResource(StandardLocation.CLASS_OUTPUT, FileKey.newName("compiler.dot.foo", "a.b.css")); OutputStream out = o.openOutputStream(); Tools.copy(in, out); Tools.safeClose(in); Tools.safeClose(out); } catch (Exception e) { throw failure(e); } } return true; } });