Refine search
private synchronized OutputStream current() throws IOException { if (current==null) try { current = Files.newOutputStream(out.toPath(), StandardOpenOption.CREATE, appendOnNextOpen ? StandardOpenOption.APPEND : StandardOpenOption.TRUNCATE_EXISTING); } catch (FileNotFoundException | NoSuchFileException | InvalidPathException e) { throw new IOException("Failed to open "+out,e); } return current; }
/** * Disable a plugin wihout checking any dependency. Only add the disable file. * @throws IOException */ private void disableWithoutCheck() throws IOException { // creates an empty file try (OutputStream os = Files.newOutputStream(disableFile.toPath())) { os.close(); } catch (InvalidPathException e) { throw new IOException(e); } }
public static void copy(InputStream in, File out) throws IOException { try (OutputStream fos = Files.newOutputStream(out.toPath())) { org.apache.commons.io.IOUtils.copy(in, fos); } catch (InvalidPathException e) { throw new IOException(e); } }
@Deprecated public OutputStream getOutputStream() throws IOException { try { return Files.newOutputStream(file.toPath()); } catch (InvalidPathException e) { throw new IOException(e); } }
/** * Gets the OutputStream to write to the file. */ public OutputStream write() throws IOException { if(gz.exists()) gz.delete(); try { return Files.newOutputStream(file.toPath()); } catch (InvalidPathException e) { throw new IOException(e); } }
/** * Copy the contents of the given byte array to the given output File. * @param in the byte array to copy from * @param out the file to copy to * @throws IOException in case of I/O errors */ public static void copy(byte[] in, File out) throws IOException { Assert.notNull(in, "No input byte array specified"); Assert.notNull(out, "No output File specified"); copy(new ByteArrayInputStream(in), Files.newOutputStream(out.toPath())); }
/** * Copy the contents of the given input File to the given output File. * @param in the file to copy from * @param out the file to copy to * @return the number of bytes copied * @throws IOException in case of I/O errors */ public static int copy(File in, File out) throws IOException { Assert.notNull(in, "No input File specified"); Assert.notNull(out, "No output File specified"); return copy(Files.newInputStream(in.toPath()), Files.newOutputStream(out.toPath())); }
@Override public OutputStream getOutputStream() throws IOException { return Files.newOutputStream(getFile().toPath()); }
/** * This implementation opens a FileOutputStream for the underlying file. * * @return The FileOutputStream * @throws IOException if there is an error * @see java.io.FileOutputStream */ public OutputStream getOutputStream() throws IOException { return Files.newOutputStream(file.toPath()); }
private OutputStream getOutputStream() throws IOException { return reportFile == null ? System.out : Files.newOutputStream(reportFile.toPath()); } }
private synchronized OutputStream current() throws IOException { if (current == null) { if (!closed) { FileUtils.forceMkdir(out.getParentFile()); try { current = Files.newOutputStream(out.toPath(), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); } catch (FileNotFoundException | NoSuchFileException | InvalidPathException e) { throw new IOException("Failed to open "+out,e); } } else { throw new IOException(out.getName()+" stream is closed"); } } return current; }
public void on() { try { file.getParentFile().mkdirs(); Files.newOutputStream(file.toPath()).close(); get(); // update state } catch (IOException | InvalidPathException e) { LOGGER.log(Level.WARNING, "Failed to touch "+file); } }
private OutputStream createLogger() throws IOException { // don't do buffering so that what's written to the listener // gets reflected to the file immediately, which can then be // served to the browser immediately try { return Files.newOutputStream(getLogFile().toPath(), StandardOpenOption.CREATE, StandardOpenOption.APPEND); } catch (InvalidPathException e) { throw new IOException(e); } }
/** * To assist boot failure script, record the number of boot attempts. * This file gets deleted in case of successful boot. * * @see BootFailure */ private void recordBootAttempt(File home) { try (OutputStream o=Files.newOutputStream(BootFailure.getBootFailureFile(home).toPath(), StandardOpenOption.CREATE, StandardOpenOption.APPEND)) { o.write((new Date().toString() + System.getProperty("line.separator", "\n")).toString().getBytes()); } catch (IOException | InvalidPathException e) { LOGGER.log(WARNING, "Failed to record boot attempts",e); } }
public FileBasedScatterGatherBackingStore(final File target) throws FileNotFoundException { this.target = target; try { os = Files.newOutputStream(target.toPath()); } catch (FileNotFoundException ex) { throw ex; } catch (IOException ex) { // must convert exception to stay backwards compatible with Compress 1.10 to 1.13 throw new RuntimeException(ex); // NOSONAR } }
/** * Write out manifest to destfile. * * @param manifest the manifest * @throws IOException if error writing file */ private void writeManifest(final Manifest manifest) throws IOException { try (OutputStream output = Files.newOutputStream(destFile.toPath())) { manifest.write(output); output.flush(); } }
TempFileCachingStreamBridge() throws IOException { f = File.createTempFile("commons-compress", "packtemp"); f.deleteOnExit(); out = Files.newOutputStream(f.toPath()); }
@Override public void transferTo(File dest) throws IOException, IllegalStateException { this.part.write(dest.getPath()); if (dest.isAbsolute() && !dest.exists()) { // Servlet 3.0 Part.write is not guaranteed to support absolute file paths: // may translate the given path to a relative location within a temp dir // (e.g. on Jetty whereas Tomcat and Undertow detect absolute paths). // At least we offloaded the file from memory storage; it'll get deleted // from the temp dir eventually in any case. And for our user's purposes, // we can manually copy it to the requested location as a fallback. FileCopyUtils.copy(this.part.getInputStream(), Files.newOutputStream(dest.toPath())); } }
/** * Copy the contents of the given input File to the given output File. * @param in the file to copy from * @param out the file to copy to * @return the number of bytes copied * @throws IOException in case of I/O errors */ public static int copy(File in, File out) throws IOException { Assert.notNull(in, "No input File specified"); Assert.notNull(out, "No output File specified"); return copy(Files.newInputStream(in.toPath()), Files.newOutputStream(out.toPath())); }
/** * Copy the contents of the given byte array to the given output File. * @param in the byte array to copy from * @param out the file to copy to * @throws IOException in case of I/O errors */ public static void copy(byte[] in, File out) throws IOException { Assert.notNull(in, "No input byte array specified"); Assert.notNull(out, "No output File specified"); copy(new ByteArrayInputStream(in), Files.newOutputStream(out.toPath())); }