File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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: 3694

Why do you want to edit Java files like that?
Roberto Perillo

Joined: Dec 28, 2007
Posts: 2270

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:
subject: Traverse and edit Java Files automatically