Two Laptop Bag*
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

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 58
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: 3603

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

Joined: Dec 28, 2007
Posts: 2258

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
Similar Threads
How to compile only specific .java files, not the whole src
How to edit class files with JDK?
how can i edit ejb-jar.xml in weblogic7.0..???
how to edit GUI file
Ant does not output property file in classes folder.