private synchronized void ensureOpened() throws IOException { if (closed) { throw new IOException(file + " has already been closed."); } if (!opened) { fos = FileUtils.newOutputStream(file.toPath(), append); opened = true; } } }
private void openFileImpl(boolean append) throws BuildException { if (out == null) { try { out = new PrintStream(FileUtils.newOutputStream(Paths.get(filename), append)); } catch (IOException ioe) { throw new BuildException("Problems opening file using a " + "recorder entry", ioe); } } }
private OutputStream getOutputStream(boolean append) throws IOException { File f = getNotNullFile(); if (f.exists()) { if (f.isFile() && !append) { f.delete(); } } else { File p = f.getParentFile(); if (p != null && !(p.exists())) { p.mkdirs(); } } return FileUtils.newOutputStream(f.toPath(), append); }
/** * access the stream to which the stderr from cvs should go * if this stream has already been set, it will be returned * if the stream has not yet been set, if the attribute error * has been set, the output stream will go to the file denoted by the error attribute * otherwise the stderr output will go to ant's logging system * @return output stream to which cvs' stderr should go to */ protected OutputStream getErrorStream() { if (this.errorStream == null) { if (error != null) { try { setErrorStream(new PrintStream( new BufferedOutputStream( FileUtils.newOutputStream(Paths.get(error.getPath()), append)))); } catch (IOException e) { throw new BuildException(e, getLocation()); } } else { setErrorStream(new LogOutputStream(this, Project.MSG_WARN)); } } return this.errorStream; }
/** * access the stream to which the stdout from cvs should go * if this stream has already been set, it will be returned * if the stream has not yet been set, if the attribute output * has been set, the output stream will go to the output file * otherwise the output will go to ant's logging system * @return output stream to which cvs' stdout should go to */ protected OutputStream getOutputStream() { if (this.outputStream == null) { if (output != null) { try { setOutputStream(new PrintStream( new BufferedOutputStream( FileUtils.newOutputStream(Paths.get(output.getPath()), append)))); } catch (IOException e) { throw new BuildException(e, getLocation()); } } else { setOutputStream(new LogOutputStream(this, Project.MSG_INFO)); } } return this.outputStream; }
/** * Execute the task. */ public void execute() { DOMElementWriter writer = new DOMElementWriter(!append, namespacePolicy.getPolicy()); OutputStream os = null; try { if (file != null) { os = FileUtils.newOutputStream(file.toPath(), append); } else { os = new LogOutputStream(this, Project.MSG_INFO); } Node n = getFragment().getFirstChild(); if (n == null) { throw new BuildException(ERROR_NO_XML); } writer.write((Element) n, os); } catch (BuildException e) { throw e; } catch (Exception e) { throw new BuildException(e); } finally { FileUtils.close(os); } }
output.as(FileProvider.class); if (fp != null) { os = FileUtils.newOutputStream(fp.getFile().toPath(), append); } else { if (append) {