Use scanner class to look at one character at a time?

regardless of white space and newlines

Page 1 of 1

2 Replies - 1987 Views - Last Post: 17 April 2010 - 03:54 PM Rate Topic: -----

#1 lunixer   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 120
  • Joined: 29-January 10

Use scanner class to look at one character at a time?

Posted 17 April 2010 - 02:58 PM

I'm writing an xml parser that I am going to use in an rss reader that I am writing. I am using a number of variables as flags to say which tags are open at the moment and when I want something I just parse out everything until I hit a < at which point I test for a close flag. My problem is that the xml file from which I am reading does not always have the xml statements (ie </whatever>) with all of the tokens on the same line. Is there any way to get the scanner class to treat the entire file as a single line, and search character by character? Or does anybody have a suggestion for another way that I can do this?

Is This A Good Question/Topic? 0
  • +

Replies To: Use scanner class to look at one character at a time?

#2 n8wxs   User is offline

  • --... ...-- -.. . -. ---.. .-- -..- ...
  • member icon

Reputation: 972
  • View blog
  • Posts: 3,878
  • Joined: 07-January 08

Re: Use scanner class to look at one character at a time?

Posted 17 April 2010 - 03:08 PM

Well you could try public boolean hasNext(Pattern pattern).

Set the pattern to be any character and have at it. :)
Was This Post Helpful? 0
  • +
  • -

#3 lunixer   User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 120
  • Joined: 29-January 10

Re: Use scanner class to look at one character at a time?

Posted 17 April 2010 - 03:54 PM

View Postn8wxs, on 17 April 2010 - 04:08 PM, said:

Well you could try public boolean hasNext(Pattern pattern).

Set the pattern to be any character and have at it. :)


I considered that, but it says that it has to be "prefixed and postfixed by input that matches the delimiter pattern" and if I do a hasNext("<") in an xml file with <item><title>somestring</title></item> it won't see any of them as tokens with that boolean.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1