• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

pattern class issue

 
arjun rampal
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I have a data file which I am reading according to following pattern

Pattern p = Pattern.compile("[\\p{Punct}&&[|]]");

Now it is reading all lines but it is not able to find out end of file so ging exception required string is empty

any idea
H480988672|AAA|AAA|2006-09-23 06:23:57|B|AAA|AAA|1|0|0|0|0|0|10|0|0|mcannone|2006-09-23|
H573193578|KAA|KAA|2006-09-23 06:23:58|B|KAA|KAA|21|0|2|0|0|0|0|0|0|pgarcia|2006-09-23|
H583114428|KAA|KAA|2006-09-23 06:23:59|B|KAA|KAA|2221|0|2|0|0|0|0|0|0|pgarcia|2006-09-23|
H480985619|AAA|AAA|2006-09-23 06:23:56|B|AAA|AAA|3|0|3|0|0|0|9|0|0|mcannone|2006-09-23
 
Tim LeMaster
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This probably belongs in beginner or intermediate - but if you are having trouble detecting the end of a file - why don't you post the file reading code?
 
arjun rampal
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String [] lineItems = p.split(line); to be replaced by
String [] lineItems = p.split(line.trim());
 
Alan Moore
Ranch Hand
Posts: 262
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't understand your question, but I can tell you that this regex: means the same thing as this:
 
arjun rampal
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi alna issue solved.I need to chaneged to line.trim()
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic