Java Parse Int parseInt(char[] input, ParsePosition offset, int length)

Here you can find the source of parseInt(char[] input, ParsePosition offset, int length)

Description

parse Int

License

Open Source License

Declaration

public static long parseInt(char[] input, ParsePosition offset, int length) 

Method Source Code

//package com.java2s;
/*/*from  w  w w.  j av  a  2 s.c  om*/
 * This file is part of the Jose Project
 * see http://jose-chess.sourceforge.net/
 * (c) 2002-2006 Peter Sch?fer
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 */

import java.text.ParsePosition;

public class Main {
    public static long parseInt(StringBuffer input, ParsePosition offset) {
        long result = 0;
        int i;
        while ((i = offset.getIndex()) < input.length()) {
            char c = input.charAt(i);
            if (c >= '0' && c <= '9') {
                result = (result * 10) + (c - '0');
                offset.setIndex(i + 1);
            } else
                break;
        }
        return result;
    }

    public static long parseInt(char[] input, ParsePosition offset, int length) {
        long result = 0;
        int i;
        while ((i = offset.getIndex()) < length) {
            char c = input[i];
            if (c >= '0' && c <= '9') {
                result = (result * 10) + (c - '0');
                offset.setIndex(i + 1);
            } else
                break;
        }
        return result;
    }
}

Related

  1. parseInt(char[] strs, int beginindex, int endindex)
  2. parseInt(String src, Locale loc)
  3. parseInt(String stringValue)
  4. parseInt(String value)