jQuery in Action, 3rd edition
The moose likes Java in General and the fly likes Traverse and edit Java Files automatically Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Traverse and edit Java Files automatically" Watch "Traverse and edit Java Files automatically" New topic

Traverse and edit Java Files automatically

yusuf Kaplan
Ranch Hand

Joined: Mar 11, 2011
Posts: 59
Hi all,

I need an API for traversing and editing Java files.
For example, I want to programmatically walk through a bunch of Java files in a directory and If I find a specific attribute or method within a Java file, then I want to remove or edit this attribute or method. I dont want to do it with BufferedReader and -Writer. Is there maybe any known libraries to help here?

Stephan van Hulst

Joined: Sep 20, 2010
Posts: 4616

Why do you want to edit Java files like that?

The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.
Roberto Perillo

Joined: Dec 28, 2007
Posts: 2271

It is pretty likely that such thing would just cause compile-time errors, since supposedly the files would still be compiled after that...

Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
I agree. Here's the link: http://aspose.com/file-tools
subject: Traverse and edit Java Files automatically
It's not a secret anymore!