• Post Reply Bookmark Topic Watch Topic
  • New Topic

Filter the contents of a file  RSS feed

 
Himani Vashistha
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I want to know if there is any java API which provides a way to filter the contents of a file.

For example I want to filter all the lines of a file which has Nullpointer entry into it.

Pleas help!
Thanks,
Himani
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's easy to write a small program that does this:

- Read the contents of a file line by line: use BufferedReader to do this.
- For each line, check if it contains the string you are looking for (use the method indexOf(...) in class String).
- If the line contains the string you're looking for, print the line (or do whatever you like with it).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!