Java 8 InputStream - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 InputStream class.

This code example shows how to use the following methods:close
    Map<String, ProcessingInstructionNode> getSocketBindingsPlaceHolders() {
        return socketBindingsPlaceHolder;
    } 
 
    void parse() throws IOException, XMLStreamException { 
        InputStream in = new BufferedInputStream(new FileInputStream(inputFile));
        try { 
            XMLInputFactory factory = XMLInputFactory.newInstance();
            factory.setProperty(XMLInputFactory.IS_COALESCING, Boolean.FALSE);
            XMLStreamReader reader = factory.createXMLStreamReader(in);
 
            reader.require(START_DOCUMENT, null, null);
            ParsingUtils.getNextElement(reader, rootElementName, null, false);
            root = super.parseNode(reader, rootElementName);
 
        } finally { 
            try { 
                in.close();
            } catch (Exception ignore) {
            } 

9
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:close
        } catch (MalformedURLException e) {
            throw new AbortException("Unable to find a script "+script);
        } 
        InputStream s = url.openStream();
        try { 
            return IOUtils.toString(s);
        } finally { 
            s.close();
        } 
    } 
 
} 
9
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:close, mark, read, reset
				osToUse = dos;
			} 
 
			if (!isToUse.markSupported()) {
				isToUse = new BufferedInputStream(isToUse);
				isToUse.mark(1);
			} 
 
			int code = isToUse.read();
			int major;
			int minor;
 
			AbstractHessianInput in;
			AbstractHessianOutput out;
 
			if (code == 'H') {
				// Hessian 2.0 stream 
				major = isToUse.read();
				minor = isToUse.read();
				if (major != 0x02) {

8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:close
        is.reset();
    } 
 
    @Override 
    public void close() throws IOException { 
        is.close();
    } 
 
    @Override 
    public int read() throws IOException { 
        return is.read();
    } 
 
    @Override 
    public int read(byte[] b) throws IOException {
        return is.read(b);
    } 
 
    @Override 
    public int read(byte[] b, int off, int len) throws IOException {
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
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
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:read
    input = checksumIn;       
   
    // Are map-outputs compressed? 
    if (codec != null) {
      decompressor.reset();
      input = codec.createInputStream(input, decompressor);
    } 
   
    try { 
      IOUtils.readFully(input, memory, 0, memory.length);
      metrics.inputBytes(memory.length);
      reporter.progress();
      LOG.info("Read " + memory.length + " bytes from map-output for " +
                getMapId()); 
 
      /** 
       * We've gotten the amount of data we were expecting. Verify the 
       * decompressor has nothing more to offer. This action also forces the 
       * decompressor to read any trailing bytes that weren't critical 
       * for decompression, which is necessary to keep the stream 

8
CodeRank
Connect your IDE to all the code out there  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
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:close
    return file;
  } 
 
  public void load() { 
    try { 
      InputStream stream = new FileInputStream(getFile());
      try { 
        properties.load(stream);
      } finally { 
        stream.close();
      } 
    } catch (FileNotFoundException e) {
      save(); 
    } catch (IOException e) {
      properties.clear();
      populate(); 
      save(); 
    } 
  } 
 
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:read
    } 
 
    private InputStream nextStream() throws IOException {
        assert initialized == false || currentStream != null;
        initialized = true;
        IOUtils.close(currentStream);
        if (slice < numSlices) {
            currentStream = openSlice(slice++);
        } else { 
            currentStream = null;
        } 
        return currentStream;
    } 
 
    /** 
     * Called for each logical slice given a zero based slice ordinal. 
     */ 
    protected abstract InputStream openSlice(long slice) throws IOException;
 
    private InputStream currentStream() throws IOException {

8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:mark, read, reset
    public int read() throws IOException { 
      if (endSeen) {
        return -1; 
      } 
 
      input.mark(10000);
 
      int result = input.read();
 
      if (result < 0) {
        endSeen = true;
        return result;
      } 
 
      if (result == markerBytes[0]) {
        input.reset();
 
        // this might be a marker line 
        int markerReadResult =
            input.read(fileMarkerBuffer, 0, fileMarkerBuffer.length);

8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related Java 8 InputStream Questions & Answers:

Other Java 8 InputStream Examples

16:	    setContentView(R.layout.activity_main);
17:	    ImageView button = (ImageView) findViewById(R.id.image);
18:	    InputStream resource = getResources().openRawResource(R.drawable.dog);
19:	    Bitmap bitmap = BitmapFactory.decodeStream(resource);
20:	    button.setBackground(new MyRoundCornerDrawable(bitmap));

Read More

35:	  @Override
36:	  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
37:	    InputStream stream = null;
38:	    if (requestCode == REQUEST_CODE && resultCode == Activity.RESULT_OK)
39:	      try {

Read More

4:	 
5:	public class Utils {
6:	    public static void CopyStream(InputStream is, OutputStream os)
7:	    {
8:	        final int buffer_size=1024;

Read More

4:	public class Utils {
5:	    public static void CopyStream(InputStream is, OutputStream os)
6:	    {
7:	        final int buffer_size=1024;
8:	        try

Read More

50:				Bitmap mIcon11 = null;
51:				try {
52:					InputStream in = new java.net.URL(urldisplay).openStream();
53:					mIcon11 = BitmapFactory.decodeStream(in);
54:				} catch (Exception e) {

Read More

See Code Examples for Java 8 InputStream Methods: