InputStream markSupported - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for InputStream markSupported method.

This code example shows how to use the following methods:available, mark, markSupported, read, reset
     * 
     * @param t            the instance of the JAXB type. 
     * @param mediaType    the meida type. 
     * @param c            the character set to serialize characters to. 
     * @param m            the marshaller to marshaller the instance of the JAXB type. 
     * @param entityStream the output stream to marshal to. 
     * @throws javax.xml.bind.JAXBException 
     */ 
    protected void writeTo(Object t, MediaType mediaType, Charset c,
                           Marshaller m, OutputStream entityStream)
            throws JAXBException { 
        m.marshal(t, entityStream);
    } 
} 

8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:mark, markSupported, read, reset
 
    @Override 
    public InputStream decode(String contentEncoding, InputStream encodedStream)
            throws IOException { 
        // correct impl. should wrap deflate in zlib, but some don't do it - have to identify, which one we got 
        InputStream markSupportingStream = encodedStream.markSupported() ? encodedStream :
                new BufferedInputStream(encodedStream);
 
        markSupportingStream.mark(1);
        // read the first byte 
        int firstByte = markSupportingStream.read();
        markSupportingStream.reset();
 
        // if using zlib, first 3 bits should be 0, 4th should be 1 
        // that should never be the case if no zlib wrapper 
        if ((firstByte & 15) == 8) {
            // ok, zlib wrapped stream 
            return new InflaterInputStream(markSupportingStream);
        } else { 
            // no zlib wrapper 
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:mark, markSupported, read, reset
            return true; 
        } 
 
        try { 
            // Try #markSupported first - #available on WLS waits until socked timeout is reached when chunked encoding is used. 
            if (input.markSupported()) {
                input.mark(1);
                int i = input.read();
                input.reset();
                return i == -1;
            } else { 
                try { 
                    if (input.available() > 0) {
                        return false; 
                    } 
                } catch (IOException ioe) {
                    // NOOP. Try other approaches as this can fail on WLS. 
                } 
 
                int b = input.read();

8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:markSupported
        is.reset();
    } 
 
    @Override 
    public boolean markSupported() { 
        return is.markSupported();
    } 
     
    @Override 
    public void close() throws IOException { 
        is.close();
    } 
 
    protected long track(long bytesRead) {
        if (bytesRead > 0) {
            this.bytesRead += bytesRead;
        } 
        return bytesRead;
    } 
} 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:mark, markSupported, read, reset
     * a buffer is extracted, leaving the stream in its original state. 
     */ 
    public final Charset detectCharset(InputStream is)
    { 
        // Only support marking streams 
        if (!is.markSupported())
        { 
            throw new IllegalArgumentException("The InputStream must support marks.  Wrap the stream in a BufferedInputStream.");
        } 
        try 
        { 
            int bufferSize = getBufferSize();
            if (bufferSize < 0)
            { 
                throw new RuntimeException("The required buffer size may not be negative: " + bufferSize);
            } 
            // Mark the stream for just a few more than we actually will need 
            is.mark(bufferSize);
            // Create a buffer to hold the data 
            byte[] buffer = new byte[bufferSize];

7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:markSupported
        parent.mark(readlimit);
    } 
 
    @Override 
    public boolean markSupported() { 
        return parent.markSupported();
    } 
 
    @Override 
    public int read(byte[] b, int off, int len) throws IOException {
        int read = super.read(b, off, len);
        position += read;
        return read;
    } 
 
    @Override 
    public int read(byte[] b) throws IOException {
        int read = parent.read(b);
        position += read;
        return read;
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:mark, markSupported, read, reset
     * @return decoder 
     */ 
    static ImageDecoder createDecoder(DecodingImageSource src, InputStream is) {
        InputStream markable;
 
        if (!is.markSupported()) {
            // BEGIN android-modified 
            markable = new BufferedInputStream(is, 8192);
            // END android-modified 
        } else { 
            markable = is;
        } 
             
        // Read the signature from the stream and then reset it back 
        try { 
            markable.mark(MAX_BYTES_IN_SIGNATURE);
 
            byte[] signature = new byte[MAX_BYTES_IN_SIGNATURE];
            markable.read(signature, 0, MAX_BYTES_IN_SIGNATURE);
            markable.reset();

7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:markSupported
			loadOutputCache(); 
		if (outputCache == null)
			return null; 
		InputStream inputStream = registerInputStream(outputCache
				.getNewInputStream()); 
		if (inputStream.markSupported())
			return inputStream;
		inputStream = registerInputStream(new BufferedInputStream(inputStream));
		return inputStream;
	} 
 
	private final InputStream registerInputStream(final InputStream inputStream) {
		inputStreamList.add(inputStream);
		return inputStream;
	} 
 
	public String getMD5Hash() throws NoSuchAlgorithmException, LimitException,
			IOException { 
		if (outputCache == null)
			loadOutputCache(); 

7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:markSupported
    wrappedInputStream.mark(readlimit);
  } 
 
  @Override 
  public boolean markSupported() { 
    return wrappedInputStream.markSupported();
  } 
 
  @Override 
  public int read(final byte[] b, final int off, final int len) throws IOException {
    if (buffer.size() > 0) {
      int tot2Read = Math.min(buffer.size(), len);
 
      for (int i = 0; i < tot2Read; ++i) {
        b[i] = (byte) buffer.remove(0).byteValue();
        contentLength--;
      } 
      return tot2Read;
    } 
 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:markSupported
    public synchronized void reset() throws IOException { 
        this.is.reset();
    } 
 
    public boolean markSupported() { 
        return this.is.markSupported();
    } 
} 
7
CodeRank
Experience pair programming with AI  Get Codota for Java

Related InputStream markSupported Questions & Answers:

markSupported Method Overview
Tests if this input stream supports the mark and reset methods.
See Code Examples for other Java 8 InputStream Methods: