• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Matcher replaceAll()

 
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
as far as i can see my code is exactly like the tutorial except i use the other Pattern constructor
it compiles but i get a NullPointerException at Matcher.getTextLength(unknown source)
the tutorial:

my code:
 
Ranch Hand
Posts: 62
5
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Randall Twede wrote:as far as i can see my code is exactly like the tutorial except i use the other Pattern constructor
it compiles but i get a NullPointerException at Matcher.getTextLength(unknown source)


My first impression is that text is null. getText() of Swing text components can return a null (see documentation) ... why you are eventually in this situation ... I don't know without seeing the rest of the code.
 
Randall Twede
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you are correct Andrea. it is null and no doubt for the reason mentioned in the API. it turns out the problem is not this code. it only throws the exception if the text comes from an rtf file. it works with plain text and html pages. there are other problems involving rtf as well. i will see what i can find out and if i need more help i will post a different thread.
reply
    Bookmark Topic Watch Topic
  • New Topic