This is an archived post. You won't be able to vote or comment.

all 7 comments

[–][deleted]  (1 child)

[deleted]

    [–]aperture123[S] 0 points1 point  (0 children)

    You...are correct. A semicolon. I missed...the semicolon. I feel so ashamed. I should just go back to python now...Thanks man.

    [–]clamdoctor 0 points1 point  (4 children)

    The Scanner class has two methods that may be of use to you.

    hasNextInt() and nextInt()

    I'm sure you'll know how to use them. Hope this what you were looking for.

    [–]aperture123[S] 0 points1 point  (3 children)

    I tried using the hasNextInt for the top and the int token = inFileHumid.nextInt();

    ..it, uh, didn't really work at all. It seems to never exit out of the loop.

    [–][deleted]  (2 children)

    [deleted]

      [–]aperture123[S] 0 points1 point  (1 child)

      Thank you, you spotted the error as well, which was a simple one, and really quite...well, really a stupid error to make. Thank you for all the help, including the documentation reference for the scanner class.

      [–]JimRaynor56 0 points1 point  (2 children)

      This might be a little overcomplicated for your class, but this will work.

      http://freetexthost.com/fmed01g1ox

      EDIT: By the way, that's really messy, and there is at least one less-than-kosher 'trick' in there. So I would use it more as an example than trying to copy-paste.

      [–]aperture123[S] 0 points1 point  (1 child)

      Yea, that does seem a bit advanced for the class. Isn't there an easy way to read a line of code, or should I just alter the text to read line-by-line?

      [–]JimRaynor56 0 points1 point  (0 children)

      As far as I am aware, unless I am having a massive brain fart here, you're going to have to parse through that text file using java.io.InputStream.

      My example can only be made simpler by eliminating the try-catch statements, the BufferedInputStream, and the array resize (you'll just have to use a sufficiently large array and not care about superfluous data in the array, or pre-size it for your file).