获得源字符串中的下一个字符

@return 下一个字符, or 0 if past the end of the source string.
@throws JSONException JSON异常，包装IO异常
555918
public char next() throws JSONException {
		int c;
		if (this.usePrevious) {
			this.usePrevious = false;
			c = this.previous;
		} else {
			try {
				c = this.reader.read();
			} catch (IOException exception) {
				throw new JSONException(exception);
			}

			if (c <= 0) { // End of stream
				this.eof = true;
				c = 0;
			}
		}
		this.index += 1;
		if (this.previous == '\r') {
			this.line += 1;
			this.character = c == '\n' ? 0 : 1;
		} else if (c == '\n') {
			this.line += 1;
			this.character = 0;
		} else {
			this.character += 1;
		}
		this.previous = (char) c;
		return this.previous;
	}
652534
@Override
    public CharSequence get() throws ExecutionException {
        try {
            this.futureBuilder.performAppends();
        } catch (IOException | HttpErrorPage e) {
            throw new ExecutionException(e);
        }
        return this.builder.toString();
    }
176121
public static long getLong(JSONValue value) {
        if (value == null)
            return 0;
        if (!(value instanceof Number))
            throw new JSONException(NOT_A_NUMBER);
        return ((Number)value).longValue();
    }
956991
private int next() throws IOException, UnterminatedCommentException {
		int c = get();
		if (c == '/') {
			switch (peek()) {
			case '/':
				for (;;) {
					c = get();
					if (c <= '\n') {
						break;
					}
				}
				break;
			case '*':
				get();
				while (c != ' ') {
					switch (get()) {
					case '*':
						if (peek() == '/') {
							get();
							c = ' ';
						}
						break;
					case EOF:
						throw new UnterminatedCommentException(currentByteIndex, line, column);
					}
				}
				break;
			}
		}
		theY = theX;
		theX = c;
		return c;
	}
886189
public String nextTo(char delimiter) throws JSONException {
		StringBuilder sb = new StringBuilder();
		for (;;) {
			char c = this.next();
			if (c == delimiter || c == 0 || c == '\n' || c == '\r') {
				if (c != 0) {
					this.back();
				}
				return sb.toString().trim();
			}
			sb.append(c);
		}
	}
1110668
public char next(char c) throws JSONException {
		char n = this.next();
		if (n != c) {
			throw this.syntaxError("Expected '" + c + "' and instead saw '" + n + "'");
		}
		return n;
	}
1079919
public String getContent(int start, int end) throws IOException
	{
		// bug, 混合回车符号也许定位不到准确行数？
		String lineSeparator = System.getProperty("line.separator");
		Reader br  = null;
		try {
			br = openReader();
			BufferedReader reader = new BufferedReader(br);
			String line = null;
			StringBuilder sb = new StringBuilder();
			int index = 0;
			while((line=reader.readLine())!=null){
				index++;
				if(index>=start&&index<=end){
					sb.append(line).append(lineSeparator);
					if(index==end){
						break;
					}
				}
			}
			return sb.toString();
		}finally {
			if(br!=null) {
				br.close();
			}
		}
		

	

	}
328279
public JsonElement get(int index) throws JsonException {
        try {
            JsonElement value = values.get(index);
            if (value == null) {
                throw new JsonException("Value at " + index + " is null.");
            }
            return value;
        } catch (IndexOutOfBoundsException e) {
            throw new JsonException("Index " + index + " out of range [0.." + values.size() + ")");
        }
    }
609896
public String getStringFrom(JsonValue json) {
    if (json.isString()) {
      return json.asString();
    } else {
      return json.toString();
    }
  }
871236
private JsonToken startParsing() throws IOException {
    JsonToken currentToken = getCurrentToken();
    // token is null at start, so get next token
    if (currentToken == null) {
      currentToken = nextToken();
    }
    Preconditions.checkArgument(currentToken != null, "no JSON input found");
    return currentToken;
  }
1234608
public String getString( String key ) {
      verifyIsNull();
      Object o = get( key );
      if( o != null ){
         return o.toString();
      }
      throw new JSONException( "JSONObject[" + JSONUtils.quote( key ) + "] not found." );
   }
713101
private char stringChar() throws JsonParserException {
    int c = advanceChar();
    if (c == -1)
      throw createParseException(null, "String was not terminated before end of input", true);
    if (c < 32)
      throw createParseException(null,
          "Strings may not contain control characters: 0x" + Integer.toString(c, 16), false);
    return (char)c;
  }
670436
public int read() throws IOException {
		if (leftover != null && leftover.remaining() > 0) {
			int b = leftover.get();
			if (leftover.remaining() == 0) {
				leftover = null;
			}
			return b;
		}
		return input.read();
	}
216868
private int parseObject() throws Exception {
        int elementsWritten = 0;
        while (jsonParser.nextToken() != null && jsonParser.getCurrentToken() != END_OBJECT) {
            if (FIELD_NAME.equals(jsonParser.getCurrentToken())) {
                String elementName = convertName(jsonParser.getCurrentName());
                //jump to element value
                jsonParser.nextToken();
                startElement(elementName);
                parseElement(elementName, false);
                endElement(elementName);
                elementsWritten++;
            } else {
                throw new ParserException("Error when parsing. Expected field name got " + jsonParser.getCurrentToken());
            }
        }
        return elementsWritten;
    }
933822
public char nextClean() throws JSONException {

        for (;;) {
            char c = next();
            if (c == '/') {
                switch (next()) {
                    case '/':
                        do {
                            c = next();
                        } while ((c != '\n') && (c != '\r') && (c != 0));
                        break;
                    case '*':
                        for (;;) {
                            c = next();
                            if (c == 0) {
                                throw syntaxError("Unclosed comment");
                            }
                            if (c == '*') {
                                if (next() == '/') {
                                    break;
                                }
                                back();
                            }
                        }
                        break;
                    default:
                        back();
                        return '/';
                }
            } else if (c == '#') {
                do {
                    c = next();
                } while ((c != '\n') && (c != '\r') && (c != 0));
            } else if ((c == 0) || (c > ' ')) {
                return c;
            }
        }
    }
848786
public Object nextValue() throws JSONException {
        char c = nextClean();
        String s;

        switch (c) {
            case '"':
            case '\'':
                return nextString(c);
            case '{':
                back();
                return new JSONObject(this);
            case '[':
                back();
                return new JSONArray(this);
        }

        /*
         * Handle unquoted text. This could be the values true, false, or
         * null, or it can be a number. An implementation (such as this one)
         * is allowed to also accept non-standard forms.
         *
         * Accumulate characters until we reach the end of the text or a
         * formatting character.
         */

        StringBuilder sb = new StringBuilder();
        char b = c;
        while (c >= ' ' && ",:]}/\\\"[{;=#".indexOf(c) < 0) {
            sb.append(c);
            c = next();
        }
        back();

        /*
         * If it is true, false, or null, return the proper value.
         */

        s = sb.toString().trim();
        if (s.equals("")) {
            throw syntaxError("Missing value.");
        }
        if (s.equalsIgnoreCase("true")) {
            return Boolean.TRUE;
        }
        if (s.equalsIgnoreCase("false")) {
            return Boolean.FALSE;
        }
        if (s.equalsIgnoreCase("null")) {
            return null;
        }

        if (s.startsWith("new Date(")) {
            try {
                Matcher matcher = Pattern.compile("^\\s*new\\s+Date\\(\\s*(\\d+)\\s*\\)\\s*$").matcher(s);
                if (matcher.find()) {
                    long time = Long.parseLong(matcher.group(1));
                    return new Date(time);
                }
            } catch (Exception e) {
                // ignored
            }
        }

        /*
         * If it might be a number, try converting it. We support the 0- and 0x-
         * conventions. If a number cannot be produced, then the value will just
         * be a string. Note that the 0-, 0x-, plus, and implied string
         * conventions are non-standard. A JSON parser is free to accept
         * non-JSON forms as long as it accepts all correct JSON forms.
         */

        if ((b >= '0' && b <= '9') || b == '.' || b == '-' || b == '+') {
            if (b == '0') {
                if (s.length() > 2 &&
                        (s.charAt(1) == 'x' || s.charAt(1) == 'X')) {
                    try {
                        return Integer.parseInt(s.substring(2), 16);
                    } catch (Exception e) {
                        /* Ignore the error */
                    }
                } else {
                    try {
                        return Integer.parseInt(s, 8);
                    } catch (Exception e) {
                        /* Ignore the error */
                    }
                }
            }
            try {
                return Integer.valueOf(s);
            } catch (Exception e) {
                try {
                    return Long.valueOf(s);
                } catch (Exception f) {
                    try {
                        return Double.valueOf(s);
                    } catch (Exception g) {
                        return s;
                    }
                }
            }
        }
        return s;
    }
1148994
private char readNext() throws IOException {
        if (cachedNext != null) {
            char next = cachedNext.charValue();
            cachedNext = null;
            return next;
        }
        int next = input.read();
        if (next == -1) {
            throw new IllegalArgumentException("Invalid JSON data: End of file");
        }
        return (char) next;
    }