/** * Stores the open container object against * the stream, eg after a Zip contents * detector has loaded the file to decide * what it contains. */ public void setOpenContainer(Object container) { openContainer = container; if (container instanceof Closeable) { tmp.addResource((Closeable) container); } }
/** * Creates a temporary file that will automatically be deleted when * the {@link #close()} method is called, returning its path. * * @return Path to created temporary file that will be deleted after closing * @throws IOException */ public Path createTempFile() throws IOException { final Path path = tempFileDir == null ? Files.createTempFile("apache-tika-", ".tmp") : Files.createTempFile(tempFileDir, "apache-tika-", ".tmp"); addResource(new Closeable() { public void close() throws IOException { Files.delete(path); } }); return path; }
public FileChannel getFileChannel() throws IOException { FileChannel channel = FileChannel.open(getPath()); tmp.addResource(channel); return channel; }
@Override public void close() throws IOException { path = null; mark = -1; // The close method was explicitly called, so we indeed // are expected to close the input stream. Handle that // by adding that stream as a resource to be tracked before // closing all of them. This way also possible exceptions from // the close() calls get managed properly. tmp.addResource(in); tmp.close(); }
public Path getPath() throws IOException { if (path == null) { if (position > 0) { throw new IOException("Stream is already being read"); } else { // Spool the entire stream into a temporary file path = tmp.createTempFile(); Files.copy(in, path, REPLACE_EXISTING); // Create a new input stream and make sure it'll get closed InputStream newStream = Files.newInputStream(path); tmp.addResource(newStream); // Replace the spooled stream with the new stream in a way // that still ends up closing the old stream if or when the // close() method is called. The closing of the new stream // is already being handled as noted above. final InputStream oldStream = in; in = new BufferedInputStream(newStream) { @Override public void close() throws IOException { oldStream.close(); } }; length = Files.size(path); } } return path; }
/** * Stores the open container object against * the stream, eg after a Zip contents * detector has loaded the file to decide * what it contains. */ public void setOpenContainer(Object container) { openContainer = container; if (container instanceof Closeable) { tmp.addResource((Closeable) container); } }
/** * Stores the open container object against * the stream, eg after a Zip contents * detector has loaded the file to decide * what it contains. */ public void setOpenContainer(Object container) { openContainer = container; if (container instanceof Closeable) { tmp.addResource((Closeable) container); } }
/** * Creates a temporary file that will automatically be deleted when * the {@link #close()} method is called, returning its path. * * @return Path to created temporary file that will be deleted after closing * @throws IOException */ public Path createTempFile() throws IOException { final Path path = tempFileDir == null ? Files.createTempFile("apache-tika-", ".tmp") : Files.createTempFile(tempFileDir, "apache-tika-", ".tmp"); addResource(new Closeable() { public void close() throws IOException { Files.delete(path); } }); return path; }
/** * Creates a temporary file that will automatically be deleted when * the {@link #close()} method is called, returning its path. * * @return Path to created temporary file that will be deleted after closing * @throws IOException */ public Path createTempFile() throws IOException { final Path path = tempFileDir == null ? Files.createTempFile("apache-tika-", ".tmp") : Files.createTempFile(tempFileDir, "apache-tika-", ".tmp"); addResource(new Closeable() { public void close() throws IOException { Files.delete(path); } }); return path; }
public FileChannel getFileChannel() throws IOException { FileChannel channel = FileChannel.open(getPath()); tmp.addResource(channel); return channel; }
@Override public void close() throws IOException { path = null; mark = -1; // The close method was explicitly called, so we indeed // are expected to close the input stream. Handle that // by adding that stream as a resource to be tracked before // closing all of them. This way also possible exceptions from // the close() calls get managed properly. tmp.addResource(in); tmp.close(); }
@Override public void close() throws IOException { path = null; mark = -1; // The close method was explicitly called, so we indeed // are expected to close the input stream. Handle that // by adding that stream as a resource to be tracked before // closing all of them. This way also possible exceptions from // the close() calls get managed properly. tmp.addResource(in); tmp.close(); }
public FileChannel getFileChannel() throws IOException { FileChannel channel = FileChannel.open(getPath()); tmp.addResource(channel); return channel; }
public Path getPath() throws IOException { if (path == null) { if (position > 0) { throw new IOException("Stream is already being read"); } else { // Spool the entire stream into a temporary file path = tmp.createTempFile(); Files.copy(in, path, REPLACE_EXISTING); // Create a new input stream and make sure it'll get closed InputStream newStream = Files.newInputStream(path); tmp.addResource(newStream); // Replace the spooled stream with the new stream in a way // that still ends up closing the old stream if or when the // close() method is called. The closing of the new stream // is already being handled as noted above. final InputStream oldStream = in; in = new BufferedInputStream(newStream) { @Override public void close() throws IOException { oldStream.close(); } }; length = Files.size(path); } } return path; }
public Path getPath() throws IOException { if (path == null) { if (position > 0) { throw new IOException("Stream is already being read"); } else { // Spool the entire stream into a temporary file path = tmp.createTempFile(); Files.copy(in, path, REPLACE_EXISTING); // Create a new input stream and make sure it'll get closed InputStream newStream = Files.newInputStream(path); tmp.addResource(newStream); // Replace the spooled stream with the new stream in a way // that still ends up closing the old stream if or when the // close() method is called. The closing of the new stream // is already being handled as noted above. final InputStream oldStream = in; in = new BufferedInputStream(newStream) { @Override public void close() throws IOException { oldStream.close(); } }; length = Files.size(path); } } return path; }
tmp.addResource(isoFile);
tmp.addResource(isoFile);