I want to replace Logger.getLogger to LogManager.getLogger in my project and project have hundreds of java files .How I do this?
-
which operating system are you using ? if it's linux base then you can do it from terminal – Vishal Gajera Mar 02 '16 at 15:09
-
i am using ubuntu 14.04 – user3297173 Mar 02 '16 at 15:10
-
can you try this, sed -i 's/old-word/new-word/g' *.java – Vishal Gajera Mar 02 '16 at 15:12
6 Answers
for i in `find -name "*java"`; do sed -i "s/Logger.getLogger/LogManager.getLogger/g" $i; done
:)

- 7,514
- 1
- 20
- 38
-
This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - [From Review](/review/low-quality-posts/11479434) – Shabbir Dhangot Mar 03 '16 at 04:31
-
On the contrary, it does *exactly* what the question asks. I don't see the problem. – Robert Bräutigam Mar 03 '16 at 07:05
-
@CreativeAndroid how does that not answer the question? This should not be flagged low quality. – Johannes Jander Mar 03 '16 at 07:55
If you're using eclipse: Select your project with left click. Press Ctrl-H, select FileSearch. Enter your searchg strin in 'Containing text', *.java 'File name patterns' in narrow the search to 'Selected resources'.Then press replace and you're done.

- 123
- 1
- 6
That is very easy to be done with sublime text. Just install it and take a look at this question -> Sublime text 2 - find and replace globally ( all files and in all directories )

- 1
- 1

- 97
- 1
- 1
- 8
Search->File menu, enter the text to search for, hit the Replace... button which will give you another dialog where you can replace tex
ctrl + h is the shortcut ;)

- 161
- 14
Most IDEs have the ability to search and find where a class or method is used. In Eclipse select a class or method, right click, references, project. If you can use both at the same time, the go through and replace. Alternatively replace your current calls with a helper method that calls your current logger and then replace the logger.

- 1,136
- 11
- 15
If you are using eclipse click on "Search" menu than search for "File", enter the text to search for and select "enclosing project", than hit the bottom right "Replace" button. After the search action is completed eclipse will show up a dialog where you can type the text to replace. Check the preview and than complete the action.

- 1,655
- 3
- 27
- 57