region InputStream Implementation
438006
@Override
    public void close() throws IOException {
        // Skip over the remaining bytes. Do not close the underlying InputStream.
        if (this.remaining > 0) {
            int toSkip = this.remaining;
            long skipped = skip(toSkip);
            if (skipped != toSkip) {
                throw new SerializationException(String.format("Read %d fewer byte(s) than expected only able to skip %d.", toSkip, skipped));
            }
        } else if (this.remaining < 0) {
            throw new SerializationException(String.format("Read more bytes than expected (%d).", -this.remaining));
        }
    }
355709
@Override
    public InputStream exportAsInputStream() {
        // Create export delegate
        final AbstractExporterDelegate<InputStream> exportDelegate = new TarBz2ExporterDelegate(this.getArchive());

        // Execute export
        return exportDelegate.export();
    }
1063063
private void init(InputStream in) throws java.io.IOException {
        if (in.available() > 2000000) {
        	throw new IOException("Font too big");
        }
        this.file = IOUtils.toByteArray(in);
        this.fsize = this.file.length;
        if (fsize > 2000000) {
        	throw new IOException("Font too big");
        }
        this.current = 0;
    }
583736
@Override
	public void setInput(InputStream is, String charset) {
		position = 0;
		limit = 0;
		boolean detectCharset = (charset == null);

		if (is == null) {
			throw new IllegalArgumentException();
		}

		try {
			if (detectCharset) {
				// read the four bytes looking for an indication of the encoding
				// in use
				int firstFourBytes = 0;
				while (limit < 4) {
					int i = is.read();
					if (i == -1) {
						break;
					}
					firstFourBytes = (firstFourBytes << 8) | i;
					buffer[limit++] = (char) i;
				}

				if (limit == 4) {
					switch (firstFourBytes) {
					case 0x00000FEFF: // UTF-32BE BOM
						charset = "UTF-32BE";
						limit = 0;
						break;

					case 0x0FFFE0000: // UTF-32LE BOM
						charset = "UTF-32LE";
						limit = 0;
						break;

					case 0x0000003c: // '<' in UTF-32BE
						charset = "UTF-32BE";
						buffer[0] = '<';
						limit = 1;
						break;

					case 0x03c000000: // '<' in UTF-32LE
						charset = "UTF-32LE";
						buffer[0] = '<';
						limit = 1;
						break;

					case 0x0003c003f: // "<?" in UTF-16BE
						charset = "UTF-16BE";
						buffer[0] = '<';
						buffer[1] = '?';
						limit = 2;
						break;

					case 0x03c003f00: // "<?" in UTF-16LE
						charset = "UTF-16LE";
						buffer[0] = '<';
						buffer[1] = '?';
						limit = 2;
						break;

					case 0x03c3f786d: // "<?xm" in ASCII etc.
						while (true) {
							int i = is.read();
							if (i == -1) {
								break;
							}
							buffer[limit++] = (char) i;
							if (i == '>') {
								String s = new String(buffer, 0, limit);
								int i0 = s.indexOf("encoding");
								if (i0 != -1) {
									while (s.charAt(i0) != '"' && s.charAt(i0) != '\'') {
										i0++;
									}
									char deli = s.charAt(i0++);
									int i1 = s.indexOf(deli, i0);
									charset = s.substring(i0, i1);
								}
								break;
							}
						}
						break;

					default:
						// handle a byte order mark followed by something other
						// than <?
						if ((firstFourBytes & 0x0ffff0000) == 0x0feff0000) {
							charset = "UTF-16BE";
							buffer[0] = (char) ((buffer[2] << 8) | buffer[3]);
							limit = 1;
						} else if ((firstFourBytes & 0x0ffff0000) == 0x0fffe0000) {
							charset = "UTF-16LE";
							buffer[0] = (char) ((buffer[3] << 8) | buffer[2]);
							limit = 1;
						} else if ((firstFourBytes & 0x0ffffff00) == 0x0efbbbf00) {
							charset = "UTF-8";
							buffer[0] = buffer[3];
							limit = 1;
						}
					}
				}
			}

			if (charset == null) {
				charset = "UTF-8";
			}

			int savedLimit = limit;
			setInput(new InputStreamReader(is, charset));
			encoding = charset;
			limit = savedLimit;

			/*
			 * Skip the optional BOM if we didn't above. This decrements limit
			 * rather than incrementing position so that <?xml version='1.0'?>
			 * is still at character 0.
			 */
			if (!detectCharset && peekCharacter() == 0xfeff) {
				limit--;
				System.arraycopy(buffer, 1, buffer, 0, limit);
			}
		} catch (Exception e) {
			throw new KriptonRuntimeException("Invalid stream or encoding: " + e, true, this.getLineNumber(), this.getColumnNumber(), getPositionDescription(), e);
		}
	}
40261
private static InputStream inputStreamFromJar(String relativePathPrefix, String src) throws IOException {
        String absoluteName = getAbsoluteName(relativePathPrefix, src);
        return XmlUtils.class.getResourceAsStream(absoluteName);
    }
1098125
public void load(InputStream stream, String separator) throws IOException, PropertiesException {
		 
		try(DataInputStream data = new DataInputStream(stream); Reader reader = new InputStreamReader(data); BufferedReader br = new BufferedReader(reader)) {
			String line;
			StringBuilder buffer = new StringBuilder();
			while ((line = br.readLine()) != null)   {
				if(Strings.trimRight(line).startsWith(LINE_COMMENT_START)) {
					// comment line, skip!
					continue;
				} else {					
					// now check if multi-line property
					if(line.endsWith(CONTINUE_ON_NEW_LINE)) {
						// middle line in multi-line, add and skip parsing
						buffer.append(line.replaceFirst("\\\\$", ""));
						continue;
					} else {
						// ordinary line, or end of multi-line: add and parse
						buffer.append(line);
					}
				}
				line = buffer.toString().trim();
				buffer.setLength(0);
				int index = -1;
				if(line.length() > 0 && (index = line.lastIndexOf(separator)) != -1) {
					String key = line.substring(0, index).trim();
					String value = line.substring(index + separator.length()).trim();
					if("@".equals(key)) {
						logger.trace("including and overriding values defined so far with file '{}'", value);
						load(value, separator);
					} else {
						logger.trace("adding '{}' => '{}'", key, value);
						this.put(key.trim(), value.trim());
					}
				}
			}
			if(buffer.length() > 0) {
				logger.warn("multi-line property '{}' is not properly terminated", buffer);
			}
		}
	}
476682
public void parseStream (InputStream stream)
        throws IOException
    {
        try {
            // read the XML input stream and construct the scene object
            _chars = new StringBuilder();
            XMLUtil.parse(this, stream);

        } catch (ParserConfigurationException pce) {
            throw (IOException) new IOException().initCause(pce);

        } catch (SAXException saxe) {
            throw (IOException) new IOException().initCause(saxe);
        }
    }
171778
public void encode(InputStream inStream, OutputStream outStream)
        throws IOException {
        int     j;
        int     numBytes;
        byte    tmpbuffer[] = new byte[bytesPerLine()];

        encodeBufferPrefix(outStream);

        while (true) {
            numBytes = readFully(inStream, tmpbuffer);
            if (numBytes == 0) {
                break;
            }
            encodeLinePrefix(outStream, numBytes);
            for (j = 0; j < numBytes; j += bytesPerAtom()) {

                if ((j + bytesPerAtom()) <= numBytes) {
                    encodeAtom(outStream, tmpbuffer, j, bytesPerAtom());
                } else {
                    encodeAtom(outStream, tmpbuffer, j, (numBytes)- j);
                }
            }
            if (numBytes < bytesPerLine()) {
                break;
            } else {
                encodeLineSuffix(outStream);
            }
        }
        encodeBufferSuffix(outStream);
    }
376561
public static void process(InputStream inputStream, StreamHandler handler, byte[] buffer) throws IOException {
    LOGGER.trace("process(InputStream, StreamHandler, byte[])");
    LOGGER.debug("buffer size: {} bytes", buffer != null ? buffer.length : "null");
    int read = -1;
    while( (read = inputStream.read(buffer)) != -1 ) {
      LOGGER.debug("{} bytes read from stream", read);
      handler.handleStreamBuffer(buffer, 0, read);
    }
  }
1142410
public InputStream toInputStream() {
        
        String text = toXml();
        return new ByteArrayInputStream(text.getBytes(StandardCharsets.UTF_8));
        
    }
246380
public void load(InputStream inputStream) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
        StringBuilder out = new StringBuilder();
        String line;

        while ((line = reader.readLine()) != null) {
            out.append(line);
            out.append(System.lineSeparator());
        }

        setScriptText(out.toString());
    }
112172
public void readFrom(final InputStream in) throws IOException {
        pointer = 0;
        size = 0;
        int n;
        do {
            n = in.read(buffer, size, buffer.length - size);
            if (n > 0) {
                size += n;
            }
            resizeIfNeeded();
        } while (n >= 0);
    }
533745
private void copyStream(InputStream inputStream) throws IOException {
		OutputStream outputStream = null;
		try {
			outputStream = getContext().getOutputStream();
			byte[] buffer = new byte[65535];
			int bufferLen;
			int totalLen = 0;
			while ((bufferLen = inputStream.read(buffer)) > 0) {
				outputStream.write(buffer, 0, bufferLen);
				totalLen += bufferLen;
			}
			getContext().getResponse().setContentLength(totalLen);
		} finally {
			if (outputStream != null) {
				outputStream.flush();
			}
		}
	}
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);
        }
    }
222955
void readFrom(InputStream in) throws IOException {
		//TODO could optimize for aligned instances
		final int size = finish - start;
		final int length = (size + 7) >> 3;
		if (length == 0) return;
		int p = size & 7;
		final int q = finish - p;
		if (p != 0) performAdj(SET, q, (long) in.read(), p);
		p = q;
		while (p > start) {
			p -= 8;
			performAdj(SET, p, (long) in.read(), 8);
		}
	}
786306
private byte[] inputStreamToByte(InputStream inputStream) {
        try {
            return IOUtils.toByteArray(inputStream);
        } catch (IOException e) {
            LOGGER.error("image inputStream to byte error", e);
            throw new FdfsUploadImageException("upload ThumbImage error", e.getCause());
        }
    }
733160
@Override
    public InputStream exportAsInputStream() {
        // Create export delegate
        final AbstractExporterDelegate<InputStream> exportDelegate = new TarExporterDelegate(this.getArchive());

        // Execute export
        return exportDelegate.export();
    }