Creates a {@link SeekableInputStream} from the given {@link java.io.InputStream}. Exception will be
thrown if failed to do so.

@throws java.io.IOException If the given input stream is not seekable.
187263
public static SeekableInputStream create(InputStream input) throws IOException {
    if (input instanceof SeekableInputStream) {
      return (SeekableInputStream) input;
    }
    if (input instanceof FileInputStream) {
      return create((FileInputStream) input);
    }
    if (input instanceof Seekable) {
      final Seekable seekable = (Seekable) input;
      return new SeekableInputStream(input) {
        @Override
        public void seek(long pos) throws IOException {
          seekable.seek(pos);
        }

        @Override
        public long getPos() throws IOException {
          return seekable.getPos();
        }

        @Override
        public boolean seekToNewSource(long targetPos) throws IOException {
          return seekable.seekToNewSource(targetPos);
        }
      };
    }

    throw new IOException("Failed to create SeekableInputStream from " + input.getClass());
  }
1258304
public static String inputStreamToString(InputStream in) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(in));
		StringBuffer buffer = new StringBuffer();
		String line;
		while ((line = br.readLine()) != null) {
			buffer.append(line);
		}
		return buffer.toString();
	}
238776
@Override
    public T fromStream(final InputStream in, final boolean close) throws IllegalArgumentException,
        DescriptorImportException {
        // Precondition check
        if (in == null) {
            throw new IllegalArgumentException("InputStream must be specified");
        }

        final Node rootNode = this.getNodeImporter().importAsNode(in, close);

        // Create the end-user view
        final Constructor<T> constructor;
        try {
            constructor = endUserViewImplType.getConstructor(String.class, Node.class);
        } catch (final NoSuchMethodException e) {
            throw new DescriptorImportException("Descriptor impl " + endUserViewImplType.getName()
                + " does not have a constructor accepting " + String.class.getName() + " and " + Node.class.getName(),
                e);
        }
        final T descriptor;
        try {
            descriptor = constructor.newInstance(descriptorName, rootNode);
        } catch (final Exception e) {
            throw new DescriptorImportException("Could not create new instance using " + constructor + " with arg: "
                + rootNode);
        }

        // Return
        return descriptor;
    }
928784
public void createResource(final InputStream inputStream, final String resourceName)
        throws JaxRxException {
        synchronized (resourceName) {
            if (inputStream == null) {
                throw new JaxRxException(400, "Bad user request");
            } else {
                try {
                    shred(inputStream, resourceName);
                } catch (final TTException exce) {
                    throw new JaxRxException(exce);
                }
            }
        }
    }
1112482
@Override
    public InputStream getInputStream() throws IOException {
        if (closed) {
            throw new IllegalStateException("JarURLConnection InputStream has been closed");
        }
        connect();
        if (jarInput != null) {
            return jarInput;
        }
        if (jarEntry == null) {
            throw new IOException("Jar entry not specified");
        }
        return jarInput = new JarURLConnectionInputStream(jarFile
                .getInputStream(jarEntry), jarFile);
    }
908367
@Override
    public <T extends Event> Stream<T> createStream(String name, KeyFinder<T> finder, ProcessingElement... processingElements) {
        return super.createStream(name, finder, processingElements);
    }
10752
private static InputStream getInputStream(File f) throws FileNotFoundException
	{
		InputStream is = new FileInputStream(f);
		try
		{
			return new GZIPInputStream(is);
		}
		catch (IOException e)
		{
			return new FileInputStream(f);
		}
	}
415096
private void init(InputStream inputStream) {
        this.inputStream = inputStream;
        currentPath = new LinkedList<Node>();
        nodeQueue = new LinkedList<XmlNode>();
        XMLInputFactory factory = XMLInputFactory.newInstance();
        factory.setProperty("javax.xml.stream.isCoalescing", true);
        factory.setProperty("javax.xml.stream.isReplacingEntityReferences", true);
        try {
            reader = factory.createXMLStreamReader(inputStream);
        } catch (XMLStreamException e) {
            throw new XmlReaderException(e);
        }
    }
93764
private static InputStream createInputStream(GraphicFactory graphicFactory, String relativePathPrefix, String src) throws IOException {
        InputStream inputStream;
        if (src.startsWith(PREFIX_ASSETS)) {
            src = src.substring(PREFIX_ASSETS.length());
            inputStream = inputStreamFromAssets(graphicFactory, relativePathPrefix, src);
        } else if (src.startsWith(PREFIX_FILE)) {
            src = src.substring(PREFIX_FILE.length());
            inputStream = inputStreamFromFile(relativePathPrefix, src);
        } else if (src.startsWith(PREFIX_JAR) || src.startsWith(PREFIX_JAR_V1)) {
            if (src.startsWith(PREFIX_JAR)) {
                src = src.substring(PREFIX_JAR.length());
            } else if (src.startsWith(PREFIX_JAR_V1)) {
                src = src.substring(PREFIX_JAR_V1.length());
            }
            inputStream = inputStreamFromJar(relativePathPrefix, src);
        } else {
            inputStream = inputStreamFromFile(relativePathPrefix, src);

            if (inputStream == null) {
                inputStream = inputStreamFromAssets(graphicFactory, relativePathPrefix, src);
            }

            if (inputStream == null) {
                inputStream = inputStreamFromJar(relativePathPrefix, src);
            }
        }

        // Fallback to internal resources
        if (inputStream == null) {
            inputStream = inputStreamFromJar("/assets/", src);
            if (inputStream != null) {
                LOGGER.info("internal resource: " + src);
            }
        }

        if (inputStream != null) {
            return inputStream;
        }

        LOGGER.severe("invalid resource: " + src);
        throw new FileNotFoundException("invalid resource: " + src);
    }
537643
public InputStream openInputStream()
    throws IOException
  {
    close();

    TempBuffer head = _head;
    _head = null;
    _tail = null;

    return new TempInputStream(head);
  }
946577
@Override
    public InputStream getInputStream() throws IOException {
        if (!exists()) {
            throw new FileNotFoundException(getPath() + " (no such file or directory)");
        }
        if (Files.isDirectory(this.path)) {
            throw new FileNotFoundException(getPath() + " (is a directory)");
        }
        return Files.newInputStream(this.path);
    }
496707
public <U> BaseSimpleReactStream<U> fromStream(final Stream<CompletableFuture<U>> stream) {

        final Stream s = stream;
        return construct(s);
    }
676883
public InputStream asInputStream() {
    final ByteBuffer byteBuffer = asReadOnlyByteBuffer();
    return new InputStream() {
      @Override
      public int read() {
        return !byteBuffer.hasRemaining() ? -1 : byteBuffer.get() & 0xFF;
      }
    };
  }
753105
@Override
	protected InputStream openStream(String path) throws IOException {
		File file = new File(path);
		if (file.isFile() && file.canRead()) {
			return new FileInputStream(path);
		} else {
			return null;
		}
	}
8810
public static InputStream fromFile(File file) throws FileNotFoundException {
		if(file != null && file.isFile() && file.canRead()) {
			return new FileInputStream(file);
		}
		return null;
	}
689513
public InputStream getInputStream()
    throws IOException
  {
    if (_indirectSource != null)
      return _indirectSource.getInputStream();
    else if (_out != null)
      return _out.openInputStream();
    else
      throw new IllegalStateException(L.l("{0}: no input stream is available",
                                          this));
  }
925485
public InputStream getInputStream()
        throws java.io.IOException
    {
        if (!_urlString.endsWith("!/"))
            return super.getInputStream();
        
        URL url = new URL(_urlString.substring(4,_urlString.length()-2));
        return url.openStream();
    }