• Post Reply Bookmark Topic Watch Topic
  • New Topic

Ron Hitchens' Java NIO book

 
Greg Ostravich
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I looked at the description on Amazon and it sounds good.
Does it have lots of code examples too?
Most O'Reilly books are really great with that (with a few exceptions) and it's always very helpful for me.
Is there a way to use regular expressions to create a filter (wrapper) for the stream in 1.4? Or do you have to create regular expressions and parse each line of data explicitly using the expression?
 
Enrique Javier
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greg,
For JDK 1.4 regular expressions are built into the String Class. Ron wrote a Top Ten article for O'Reilly's OnJava website http://www.onjava.com/pub/a/onjava/2002/10/02/javanio.html back in October last year, look at number 9.
[ April 15, 2003: Message edited by: Enrique Javier ]
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Regular expressions don't really work directly on streams - you read from the stream to make a String (or other CharSequence object like CharBuffer). Reading line by line is probably the simplest way to do this - or read the entire stream contents into memory before applying a regex. If you try to apply a regex to a partially-read line, you have to worry about what to do if the pattern you're looking for is split between one read and another - and this is probably more trouble than you want to deal with, unless you have specific needs which require it.
 
Ron Hitchens
Author
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Code Examples: All the code examples from my book, plus some others, are online at my Java NIO book site. Of course, you should still buy the book (assuming you don't win a free copy here)
The regular expressions which are part of NIO operate on a new interface in JDK 1.4 named CharSequence. CharSequence is implemented by String, StringBuffer and CharBuffer (a new NIO class). Unless you make a special implementation of CharSequence which does something fancy, this means all the chars you want to apply the regex to must be in memory at once.
There are several regex examples on my site, one of which is a fairly sophisticated .
 
Ron Hitchens
Author
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, so the CODE tag doesn't mean typewriter font. I'll get the hang of this thing before long...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!