User Profile

Collapse

Profile Sidebar

Collapse
javanianewbie
javanianewbie
Last Activity: Oct 21 '09, 09:06 PM
Joined: Oct 13 '09
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Thank you all for the help.

    I had tried:

    Code:
    sPop = Integer.parseInt(input.substring(32,40).trim()); // breaks here
    And it wasnt working. I now realize this was due to the fact that in some parts of the file it wasnt finding ints and was breaking. Now with the try/catch Im up and running. I do however, want to improve on this and mess around with pbrockway's suggestion.

    Once again thank you...
    See more | Go to post

    Leave a comment:


  • javanianewbie
    started a topic Trouble parsing int while reading a file
    in Java

    Trouble parsing int while reading a file

    Hello,

    I am having trouble when I read in a a file and parsing part of it as an int using substring.

    Here is the code I have:

    Code:
    String input = "";
    
    while(readFile.hasNextLine()) 
    {
         input = readFile.nextLine();
         String sName = input.substring(0, 14);
         String sCap = input.substring(15,29);
         String sAbbr = input.substring(30,32);
    ...
    See more | Go to post

  • javanianewbie
    replied to substring
    in Java
    Think I figured out how to parse it

    Code:
    int sRegNum = Integer.parseInt(input.substring(56));
    Thanks for the help!
    See more | Go to post

    Leave a comment:


  • javanianewbie
    replied to substring
    in Java
    Thanks for the quick reply.

    Will I be able to use the parse int method in the same while statement using substring, or will I have to read it seperate?
    See more | Go to post

    Leave a comment:


  • javanianewbie
    started a topic substring
    in Java

    substring

    Hello,

    I am reading in a file and breaking it up using substring. This is working well except for the last part I need to read in needs to be an integer, not a string. I was curious if it is possible to use substring to break up both strings and ints.

    Here is the code I have:

    Code:
    String input = "";
    
    while(readFile.hasNextLine())
                {
    ...
    See more | Go to post
No activity results to display
Show More
Working...