You have blanks at the end of your string "00001 ". That's why the string can not be parsed as an integer. you can trim the string and the exception will gone:

intofid[i]=Integer.parseInt(mystr.trim());
Answer from Jens on Stack Overflow
🌐
Tutorialspoint
tutorialspoint.com › java › number_parseint.htm
Java - parseInt() Method
Java Vs. C++ ... This method is used to get the primitive data type of a certain String. parseXxx() is a static method and can have one argument or two. ... parseInt(int i) − This returns an integer, given a string representation of decimal, ...
🌐
Stack Overflow
stackoverflow.com › questions › 77137174 › how-to-correctly-use-parseint-in-java
eclipse - How to correctly use parseInt in Java? - Stack Overflow
The short answer is that you use String.split() to break this string up into separate elements, like the numbers and the plus sign, then you test each element to do something with it. If the element is a number, you call parseInt() on it.
🌐
The Eclipse Foundation
eclipse.org › forums › index.php › t › 1105541
Eclipse Community Forums: Newcomers » ParseInt for Java in Eclipse? | The Eclipse Foundation
The Eclipse Foundation - home to a global community, the Eclipse IDE, Jakarta EE and over 350 open source projects, including runtimes, tools and frameworks.
🌐
Coderanch
coderanch.com › t › 624034 › java › Eclipse-find-parseInt
Eclipse can't find parseInt(), and neither can I (Beginning Java forum at Coderanch)
Eclipse says "Integer.parseInt(String, int) line: Not available", and the debug window has in Red " Source not found", with a button to "Edit Source Lookup Path..." I've looked around but don't see the source to Integer.parseInt() anywhere. Where should it be? The source code for the core libraries, is located in a "src.zip" file. And that file should be located where you installed the JDK. You need to point Eclipse to that file. Henry · Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor) Jim Venolia ·
🌐
Study.com
study.com › courses › business courses › business 104: information systems and computer applications
How to Convert String to Int in Java - ParseInt Method - Lesson | Study.com
January 9, 2023 - In order to catch the exceptions, place the parseInt function within a try and catch block. The code you want to execute is inside the try statement. After the catch statement, you can display an error should the conversion fail. Since we're trying to convert a non-numeric number to numeric, the exception will be a NumberFormatException in the Java compiler. The code to wrap the pareseInt() function in a try and catch block is displayed here: String myString = newString("hello"); try { int makeNumber = Integer.parseInt(myString); System.out.println(makeNumber); } catch (NumberFormatexception e) { System.out.println("That wasn't a number!"); }
🌐
Java67
java67.com › 2015 › 08 › 2-ways-to-parse-string-to-int-in-java.html
2 ways to parse String to int in Java - Example Tutorial | Java67
Later we convert that String using both Integer.parseInt() and Integer.valueOf() method to show that both methods work and you can use either of them. Here is our complete Java program to parse a given String to an int value in Java. You can run this program in your favorite IDEs like Visual Studio Code, Eclipse, or IntelliJ IDEA ·
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › java › how-to-convert-string-to-int-in-java
String to int in Java - GeeksforGeeks
The most common method to convert a string to a primitive int is Integer.parseInt(). It throws a NumberFormatException if the string contains non-numeric characters. ... // Java Program to demonstrate // String to int conversion using parseInt() public class StringToInt { public static void main(String[] args) { String s = "12345"; // Convert the string to an integer // using Integer.parseInt() int n = Integer.parseInt(s); System.out.println("" + n); } }
Published   July 23, 2025
🌐
Mkyong
mkyong.com › home › java › how to convert string to int in java
How to convert String to int in Java - Mkyong.com
January 26, 2022 - In Java, we can use Integer.parseInt(String) to convert a String to an int; For unparsable String, it throws NumberFormatException.
🌐
Upgrad
upgrad.com › home › tutorials › software & tech › parseint in java
parseInt in Java: Everything You should Know | upGrad
June 25, 2025 - Learn how to use parseInt in Java to convert strings to integers. Understand its parameters, return values, examples, and how it compares with valueOf().
🌐
Global Tech Council
globaltechcouncil.org › home › what is parseint in java?
What is parseInt in Java? - Global Tech Council
July 5, 2025 - If the string is something like “123”, using parseInt(“123”) will give you the integer 123. Java allows you to specify a “radix” (the base of the number system) when converting strings to integers.
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › lang › Integer.html
Integer (Java Platform SE 8 )
October 20, 2025 - The characters in the string must all be decimal digits, except that the first character may be an ASCII minus sign '-' ('\u002D') to indicate a negative value or an ASCII plus sign '+' ('\u002B') to indicate a positive value. The resulting integer value is returned, exactly as if the argument and the radix 10 were given as arguments to the parseInt(java.lang.String, int) method.
🌐
Scaler
scaler.com › home › topics › parseint() in java
parseInt() in Java - Scaler Topics
May 8, 2024 - Following are how the parseInt() method can be declared in java : ... It is used in java for converting a string value to an integer by using the method parseInt().
Top answer
1 of 8
47

Usually this is done like this:

  • init result with 0
  • for each character in string do this
    • result = result * 10
    • get the digit from the character ('0' is 48 ASCII (or 0x30), so just subtract that from the character ASCII code to get the digit)
    • add the digit to the result
  • return result

Edit: This works for any base if you replace 10 with the correct base and adjust the obtaining of the digit from the corresponding character (should work as is for bases lower than 10, but would need a little adjusting for higher bases - like hexadecimal - since letters are separated from numbers by 7 characters).

Edit 2: Char to digit value conversion: characters '0' to '9' have ASCII values 48 to 57 (0x30 to 0x39 in hexa), so in order to convert a character to its digit value a simple subtraction is needed. Usually it's done like this (where ord is the function that gives the ASCII code of the character):

digit = ord(char) - ord('0')

For higher number bases the letters are used as 'digits' (A-F in hexa), but letters start from 65 (0x41 hexa) which means there's a gap that we have to account for:

digit = ord(char) - ord('0')
if digit > 9 then digit -= 7

Example: 'B' is 66, so ord('B') - ord('0') = 18. Since 18 is larger than 9 we subtract 7 and the end result will be 11 - the value of the 'digit' B.

One more thing to note here - this works only for uppercase letters, so the number must be first converted to uppercase.

2 of 8
28

The source code of the Java API is freely available. Here's the parseInt() method. It's rather long because it has to handle a lot of exceptional and corner cases.

public static int parseInt(String s, int radix) throws NumberFormatException {
    if (s == null) {
        throw new NumberFormatException("null");
    }

    if (radix < Character.MIN_RADIX) {
        throw new NumberFormatException("radix " + radix +
            " less than Character.MIN_RADIX");
    }

    if (radix > Character.MAX_RADIX) {
        throw new NumberFormatException("radix " + radix +
            " greater than Character.MAX_RADIX");
    }

    int result = 0;
    boolean negative = false;
    int i = 0, max = s.length();
    int limit;
    int multmin;
    int digit;

    if (max > 0) {
        if (s.charAt(0) == '-') {
            negative = true;
            limit = Integer.MIN_VALUE;
            i++;
        } else {
            limit = -Integer.MAX_VALUE;
        }
        multmin = limit / radix;
        if (i < max) {
            digit = Character.digit(s.charAt(i++), radix);
            if (digit < 0) {
                throw NumberFormatException.forInputString(s);
            } else {
                result = -digit;
            }
        }
        while (i < max) {
            // Accumulating negatively avoids surprises near MAX_VALUE
            digit = Character.digit(s.charAt(i++), radix);
            if (digit < 0) {
                throw NumberFormatException.forInputString(s);
            }
            if (result < multmin) {
                throw NumberFormatException.forInputString(s);
            }
            result *= radix;
            if (result < limit + digit) {
                throw NumberFormatException.forInputString(s);
            }
            result -= digit;
        }
    } else {
        throw NumberFormatException.forInputString(s);
    }
    if (negative) {
        if (i > 1) {
            return result;
        } else { /* Only got "-" */
            throw NumberFormatException.forInputString(s);
        }
    } else {
        return -result;
    }
}
🌐
iO Flood
ioflood.com › blog › parseint-java
parseInt() Java Method: From Strings to Integers
February 26, 2024 - The string is passed as an argument to the method, which then returns the integer value. The result is then printed to the console, outputting ‘123’. This is a basic way to use parseInt in Java, but there’s much more to learn about string to integer conversion.
🌐
HappyCoders.eu
happycoders.eu › java › convert-string-to-int-peculiarities-pitfalls
How to Convert String to Int in Java – Peculiarities and Pitfalls
December 2, 2024 - The second case is different: here, the result is converted to an Integer object inside Integer.valueOf() and then back to an int primitive when it is assigned to i. IntelliJ recognizes this (Eclipse doesn't) and displays a warning with the recommendation to replace valueOf() with parseInt(): ... We will examine the extent to which the compiler or HotSpot forgives us for this error in the next chapter, "performance". Similar to the last article, I did the following comparison measurements with the Java Microbenchmark Harness – JMH: Speed of various String-to-int conversion methods with Java 8: