------------------------------------------------------------------------- Methods to read values from the string stream -------------------------------------------------------------------------
515153
function(allowQuestionMark){
        var reader  = this._reader,
            part = "",
            c       = reader.peek();

        //first read hex digits
        while(isHexDigit(c) && part.length < 6){
            reader.read();
            part += c;
            c = reader.peek();
        }

        //then read question marks if allowed
        if (allowQuestionMark){
            while(c == "?" && part.length < 6){
                reader.read();
                part += c;
                c = reader.peek();
            }
        }

        //there can't be any other characters after this point

        return part;
    }
837360
@Override
    public Object readMap(AbstractHessianInput in)
        throws IOException
    {
        Object value = null;

        while (!in.isEnd()) {
            String key = in.readString();

            if (key.equals("value"))
                value = readStreamValue(in);
            else
                in.readObject();
        }

        in.readMapEnd();

        return value;
    }
937751
private static void writeValue(ObjectOutput out, Fieldable field) throws IOException
   {
      Object o = field.stringValue();
      if (o != null)
      {
         // Use writeObject instead of writeUTF because the value could contain unsupported
         // characters
         out.writeObject(o);
         return;
      }
      o = field.tokenStreamValue();
      if (o != null)
      {
         out.writeObject(o);
         return;
      }
      o = field.readerValue();
      throw new RuntimeException("Unsupported value " + o);
   }
366959
@Override
  public void readFrom(StreamInput in) throws IOException {
    super.readFrom(in);

    isPruned = in.readBoolean();
    size = in.readVInt();
    termsEncoding = TermsByQueryRequest.TermsEncoding.values()[in.readVInt()];
    encodedTerms = in.readBytesRef();
  }
226899
void readToData(boolean returnOnYield)
        throws IOException
    {
        InputStream is = getInputStream();

        if (is == null)
            return;

        for (int tag = is.read(); tag >= 0; tag = is.read()) {
            switch (tag) {
                case 'Y':
                    server.freeReadLock();
                    if (returnOnYield)
                        return;
                    server.readChannel(channel);
                    break;

                case 'Q':
                    server.freeReadLock();
                    this.is = null;
                    this.server = null;
                    return;

                case 'U':
                    this.url = readUTF();
                    break;

                case 'D':
                    chunkLength = (is.read() << 8) + is.read();
                    return;

                default:
                    readTag(tag);
                    break;
            }
        }
    }
652946
@Override
	public int read(char[] cbuf, int off, int len) throws IOException {
		try {
			if (closed) {
				throw new IOException("Attempt to read from a closed stream"); //$NON-NLS-1$
			}
			if (eof) {
				return -1;
			}
			if (curr == null) {
				curr = getNextInputReader();
				if (curr == null) {
					eof = true;
					return -1;
				}
			}
			int size, bytesRead = 0, bytesToRead = len;
			while (!eof && bytesRead < bytesToRead) {
				size = curr
						.read(cbuf, off + bytesRead, bytesToRead - bytesRead);
				if (size == -1) {
					curr.close();
					curr = getNextInputReader();
					if (curr == null) {
						eof = true;
					}
				} else {
					bytesRead += size;
				}
			}
			return bytesRead;
		} catch (IOException e) {
			throw e;
		} catch (Exception e) {
			throw new IOException(e);
		}
	}
753775
private void readObject(java.io.ObjectInputStream s)
        throws java.io.IOException, ClassNotFoundException {
        java.io.ObjectInputStream.GetField fields = s.readFields();
        char[] value = (char[])fields.get("value", null);
        int count = fields.get("count", 0);
        append(value, 0, count);
    }
1271425
@Override
	public void read(final DataInput in) throws IOException {
		int size = in.readInt();
		this.map.clear();

		try {
			for (; size > 0; size--) {
				final K key = this.keyClass.newInstance();
				final V val = this.valueClass.newInstance();
				key.read(in);
				val.read(in);
				this.map.put(key, val);
			}
		} catch (final InstantiationException e) {
			throw new RuntimeException(e);
		} catch (final IllegalAccessException e) {
			throw new RuntimeException(e);
		}
	}
900068
static public void main(String ... args) throws Exception {
        FileInputStream fin = new FileInputStream(args[0]);
        XMLReader<Sample> reader = new XMLReader<Sample>();
        
        for( Map<String,Object> map : reader.read(fin, Sample.class) ) {
            System.out.println("Next...");
            for( Map.Entry<String,Object> entry : map.entrySet() ) {
                System.out.println("\t" + entry.getKey() + " (" + (entry.getValue() != null ? entry.getValue().getClass().getName() : "") + "): " + entry.getValue());
            }
        }
    }
129861
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
        // read values
        in.defaultReadObject();

        OutputStream output = getOutputStream();
        if (cachedContent != null) {
            output.write(cachedContent);
        }
        output.close();

        cachedContent = null;
    }
390785
public static String read(InputStream in) throws IOException {
        InputStreamReader isReader = new InputStreamReader(in, "UTF-8");
        BufferedReader reader = new BufferedReader(isReader);
        StringBuffer out = new StringBuffer();
        char[] c = new char[4096];
        for (int n; (n = reader.read(c)) != -1;) {
            out.append(new String(c, 0, n));
        }
        reader.close();

        return out.toString();
    }
449678
String readString() throws IOException {
		StringBuilder sb = new StringBuilder(50);
		// first char must be ":
		char ch = reader.next();
		if (ch != '\"') {
			throw new JsonParseException("Expected \" but actual is: " + ch,
					reader.readed);
		}
		for (;;) {
			ch = reader.next();
			if (ch == '\\') {
				// escape: \" \\ \/ \b \f \n \r \t
				char ech = reader.next();
				switch (ech) {
				case '\"':
					sb.append('\"');
					break;
				case '\\':
					sb.append('\\');
					break;
				case '/':
					sb.append('/');
					break;
				case 'b':
					sb.append('\b');
					break;
				case 'f':
					sb.append('\f');
					break;
				case 'n':
					sb.append('\n');
					break;
				case 'r':
					sb.append('\r');
					break;
				case 't':
					sb.append('\t');
					break;
				case 'u':
					// read an unicode uXXXX:
					int u = 0;
					for (int i = 0; i < 4; i++) {
						char uch = reader.next();
						if (uch >= '0' && uch <= '9') {
							u = (u << 4) + (uch - '0');
						} else if (uch >= 'a' && uch <= 'f') {
							u = (u << 4) + (uch - 'a') + 10;
						} else if (uch >= 'A' && uch <= 'F') {
							u = (u << 4) + (uch - 'A') + 10;
						} else {
							throw new JsonParseException("Unexpected char: " + uch,
									reader.readed);
						}
					}
					sb.append((char) u);
					break;
				default:
					throw new JsonParseException("Unexpected char: " + ch,
							reader.readed);
				}
			} else if (ch == '\"') {
				// end of string:
				break;
			} else if (ch == '\r' || ch == '\n') {
				throw new JsonParseException("Unexpected char: " + ch,
						reader.readed);
			} else {
				sb.append(ch);
			}
		}
		return sb.toString();
	}
837086
@Override
    public int read() throws IOException {
        final StringBuilder s = read(1);
        given(s, 1, 1);
        return s.length() > 0 ? s.charAt(0) : -1;
    }
418540
function stringToStream(string) {
    let s = new stream.Readable();
    s.push(string);
    s.push(null);
    return s;
}
998874
private void deserializeMethod(ObjectInput stream) throws IOException, ClassNotFoundException {
        MethodValues method = null;
        if (SERIALIZATION_V2 == getDeserializationVersion()) {
            method = MethodValues.find(readByteArray(stream));
        } else {
            method = MethodValues.find((String) stream.readObject());
        }
        if (null == method) {
            throw new IOException("Missing method");
        }
        setMethod(method);
    }
535328
@Override
    public int read(byte[] output, int offset, int length) throws IOException {
        synchronized(this){
            int value = 0;
            if(closed) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isErrorEnabled())
                    Tr.error(tc, "stream.is.closed.no.read.write");
                throw new IOException(Tr.formatMessage(tc, "stream.is.closed.no.read.write"));
            }
            if(output == null){
                if (TraceComponent.isAnyTracingEnabled() && tc.isErrorEnabled())
                    Tr.error(tc, "read.write.bytearray.null");
                throw new NullPointerException(Tr.formatMessage(tc, "read.write.bytearray.null"));
            }
            if((offset < 0) || (length < 0) || (length > (output.length - offset))){
                if (TraceComponent.isAnyTracingEnabled() && tc.isErrorEnabled())
                    Tr.error(tc, "read.write.offset.length.bytearraylength", new Object[] {offset, length, output.length});
                throw new IndexOutOfBoundsException(Tr.formatMessage(tc, "read.write.offset.length.bytearraylength", new Object[] {offset, length, output.length}));
            }

            if (this._inBuffer != null) {
                value = _inBuffer.read(output, offset, length);
            }
            else {
                value = this.in.read(output, offset, length);
            }

            return value;
        }
    }
757263
@Nullable
    public static String readUTF(@NotNull final InputStream stream) throws IOException {
        final DataInputStream dataInput = new DataInputStream(stream);
        if (stream instanceof ByteArraySizedInputStream) {
            final ByteArraySizedInputStream sizedStream = (ByteArraySizedInputStream) stream;
            final int streamSize = sizedStream.size();
            if (streamSize >= 2) {
                sizedStream.mark(Integer.MAX_VALUE);
                final int utfLen = dataInput.readUnsignedShort();
                if (utfLen == streamSize - 2) {
                    boolean isAscii = true;
                    final byte[] bytes = sizedStream.toByteArray();
                    for (int i = 0; i < utfLen; ++i) {
                        if ((bytes[i + 2] & 0xff) > 127) {
                            isAscii = false;
                            break;
                        }
                    }
                    if (isAscii) {
                        return fromAsciiByteArray(bytes, 2, utfLen);
                    }
                }
                sizedStream.reset();
            }
        }
        try {
            String result = null;
            StringBuilder builder = null;
            for (; ; ) {
                final String temp;
                try {
                    temp = dataInput.readUTF();
                    if (result != null && result.length() == 0 &&
                        builder != null && builder.length() == 0 && temp.length() == 0) {
                        break;
                    }
                } catch (EOFException e) {
                    break;
                }
                if (result == null) {
                    result = temp;
                } else {
                    if (builder == null) {
                        builder = new StringBuilder();
                        builder.append(result);
                    }
                    builder.append(temp);
                }
            }
            return (builder != null) ? builder.toString() : result;
        } finally {
            dataInput.close();
        }
    }