/** * Return a new InputStream representing a subset of the data * from this InputStream, starting at <code>start</code> (inclusive) * up to <code>end</code> (exclusive). <code>start</code> must be * non-negative. If <code>end</code> is -1, the new stream ends * at the same place as this stream. The returned InputStream * will also implement the SharedInputStream interface. * * @param start the starting position * @param end the ending position + 1 * @return the new stream */ public synchronized InputStream newStream(long start, long end) { if (in == null) throw new RuntimeException("Stream closed"); if (start < 0) throw new IllegalArgumentException("start < 0"); if (end == -1) end = datalen; return new SharedFileInputStream(sf, this.start + start, end - start, bufsize); }
/** * Return a new InputStream representing a subset of the data * from this InputStream, starting at <code>start</code> (inclusive) * up to <code>end</code> (exclusive). <code>start</code> must be * non-negative. If <code>end</code> is -1, the new stream ends * at the same place as this stream. The returned InputStream * will also implement the SharedInputStream interface. * * @param start the starting position * @param end the ending position + 1 * @return the new stream */ @Override public synchronized InputStream newStream(long start, long end) { if (in == null) throw new RuntimeException("Stream closed"); if (start < 0) throw new IllegalArgumentException("start < 0"); if (end == -1) end = datalen; return new SharedFileInputStream(sf, this.start + start, end - start, bufsize); }
public FileMimeMessageSource(File file) throws IOException { this.file = file; this.in = new SharedFileInputStream(file); }
/** * Get an input stream to retrieve the data stored in the temporary file * * @return a <code>BufferedInputStream</code> containing the data */ public synchronized InputStream getInputStream() throws IOException { SharedFileInputStream in = new SharedFileInputStream(file); streams.add(in); return in; }
/** * Return a new InputStream representing a subset of the data * from this InputStream, starting at <code>start</code> (inclusive) * up to <code>end</code> (exclusive). <code>start</code> must be * non-negative. If <code>end</code> is -1, the new stream ends * at the same place as this stream. The returned InputStream * will also implement the SharedInputStream interface. * * @param start the starting position * @param end the ending position + 1 * @return the new stream */ @Override public synchronized InputStream newStream(long start, long end) { if (in == null) throw new RuntimeException("Stream closed"); if (start < 0) throw new IllegalArgumentException("start < 0"); if (end == -1) end = datalen; return new SharedFileInputStream(sf, this.start + start, end - start, bufsize); }
/** * Return a new InputStream representing a subset of the data * from this InputStream, starting at <code>start</code> (inclusive) * up to <code>end</code> (exclusive). <code>start</code> must be * non-negative. If <code>end</code> is -1, the new stream ends * at the same place as this stream. The returned InputStream * will also implement the SharedInputStream interface. * * @param start the starting position * @param end the ending position + 1 * @return the new stream */ @Override public synchronized InputStream newStream(long start, long end) { if (in == null) throw new RuntimeException("Stream closed"); if (start < 0) throw new IllegalArgumentException("start < 0"); if (end == -1) end = datalen; return new SharedFileInputStream(sf, this.start + start, end - start, bufsize); }
/** * Return a new InputStream representing a subset of the data * from this InputStream, starting at <code>start</code> (inclusive) * up to <code>end</code> (exclusive). <code>start</code> must be * non-negative. If <code>end</code> is -1, the new stream ends * at the same place as this stream. The returned InputStream * will also implement the SharedInputStream interface. * * @param start the starting position * @param end the ending position + 1 * @return the new stream */ @Override public synchronized InputStream newStream(long start, long end) { if (in == null) throw new RuntimeException("Stream closed"); if (start < 0) throw new IllegalArgumentException("start < 0"); if (end == -1) end = datalen; return new SharedFileInputStream(sf, this.start + start, end - start, bufsize); }
/** * Return a new InputStream representing a subset of the data * from this InputStream, starting at <code>start</code> (inclusive) * up to <code>end</code> (exclusive). <code>start</code> must be * non-negative. If <code>end</code> is -1, the new stream ends * at the same place as this stream. The returned InputStream * will also implement the SharedInputStream interface. * * @param start the starting position * @param end the ending position + 1 * @return the new stream */ @Override public synchronized InputStream newStream(long start, long end) { if (in == null) throw new RuntimeException("Stream closed"); if (start < 0) throw new IllegalArgumentException("start < 0"); if (end == -1) end = datalen; return new SharedFileInputStream(sf, this.start + start, end - start, bufsize); }
/** * Return a new InputStream representing a subset of the data * from this InputStream, starting at <code>start</code> (inclusive) * up to <code>end</code> (exclusive). <code>start</code> must be * non-negative. If <code>end</code> is -1, the new stream ends * at the same place as this stream. The returned InputStream * will also implement the SharedInputStream interface. * * @param start the starting position * @param end the ending position + 1 * @return the new stream */ @Override public synchronized InputStream newStream(long start, long end) { if (in == null) throw new RuntimeException("Stream closed"); if (start < 0) throw new IllegalArgumentException("start < 0"); if (end == -1) end = datalen; return new SharedFileInputStream(sf, this.start + start, end - start, bufsize); }
/** * Return a new InputStream representing a subset of the data * from this InputStream, starting at <code>start</code> (inclusive) * up to <code>end</code> (exclusive). <code>start</code> must be * non-negative. If <code>end</code> is -1, the new stream ends * at the same place as this stream. The returned InputStream * will also implement the SharedInputStream interface. * * @param start the starting position * @param end the ending position + 1 * @return the new stream */ public synchronized InputStream newStream(long start, long end) { if (in == null) throw new RuntimeException("Stream closed"); if (start < 0) throw new IllegalArgumentException("start < 0"); if (end == -1) end = datalen; return new SharedFileInputStream(sf, this.start + (int)start, (int)(end - start), bufsize); }
/** * Return a new InputStream representing a subset of the data * from this InputStream, starting at <code>start</code> (inclusive) * up to <code>end</code> (exclusive). <code>start</code> must be * non-negative. If <code>end</code> is -1, the new stream ends * at the same place as this stream. The returned InputStream * will also implement the SharedInputStream interface. * * @param start the starting position * @param end the ending position + 1 * @return the new stream */ public InputStream newStream(long start, long end) { if (in == null) throw new RuntimeException("Stream closed"); if (start < 0) throw new IllegalArgumentException("start < 0"); if (end == -1) end = datalen; return new SharedFileInputStream(sf, this.start + (int)start, (int)(end - start), bufsize); }
/** * Return a new InputStream representing a subset of the data * from this InputStream, starting at <code>start</code> (inclusive) * up to <code>end</code> (exclusive). <code>start</code> must be * non-negative. If <code>end</code> is -1, the new stream ends * at the same place as this stream. The returned InputStream * will also implement the SharedInputStream interface. * * @param start the starting position * @param end the ending position + 1 * @return the new stream */ @Override public synchronized InputStream newStream(long start, long end) { if (in == null) throw new RuntimeException("Stream closed"); if (start < 0) throw new IllegalArgumentException("start < 0"); if (end == -1) end = datalen; return new SharedFileInputStream(sf, this.start + start, end - start, bufsize); }
/** * Create a new stream from this stream, using the given * start offset and length. * * @param offset The offset relative to the start of this stream instance. * @param end The end offset of the substream. If -1, the end of the parent stream is used. * * @return A new SharedFileInputStream object sharing the same source * input file. */ public InputStream newStream(long offset, long end) { checkOpenRuntime(); if (offset < 0) { throw new IllegalArgumentException("Start position is less than 0"); } // the default end position is the datalen of the one we're spawning from. if (end == -1) { end = datalen; } // create a new one using the private constructor return new SharedFileInputStream(source, start + (int)offset, (int)(end - offset), bufsize); }
bodyStartOctet = 0; try (SharedFileInputStream contentIn = new SharedFileInputStream(file)) { final int size = (int) file.length();