File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Skip Line/Pattern with Scanner class

 
Viv Singh
Ranch Hand
Posts: 73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have the following content in a file:

Drives
********
cdr LITEON DVD-ROM LTD163 GDHA
cdr HL-DT-ST CD-RW GCE-8400B B104

My aim is to extract the information of both drives and I have written the following code:



I use s.nextLine() to skip the pattern *******, I tried to use the built in method skip as follows:

s.skip("*******");

but that did not work. Am I doing something wrong?

thanks in advance.
 
Rob Spoor
Sheriff
Pie
Posts: 20380
45
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
* is part of regular expressions, so you will need to escape it with a \ (which again must be escaped because it is part of a string):
Of course, this can be shortened by using the count operator:
See Pattern for more information on regular expressions.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic