0

Is there an elegant way to parse Java sourcecode and to isolate its Strings?

I would like to do that to copy all Strings into an office file with which I can run German spell-checking.

2
  • Do you want to do that with Java? I would use Perl to read the .java files and search for regexes in the file Commented Nov 5, 2013 at 15:08
  • 2
    Have you tried to remove the check on "Ignore Java String literals" in the Eclipse settings for the spell checker and adding a german user dictionary? Commented Nov 5, 2013 at 15:10

3 Answers 3

1

You could use properties files

http://www.java-forums.org/blogs/java-basic/974-how-use-properties-file-java.html

Sign up to request clarification or add additional context in comments.

3 Comments

if German is the only supported language, then it seems overkill to add property files only for spell checking.
Leaves you with the nice side effects of being able to internationalise very easily and reuse text though.
Copy and paste the properties file into MsOffice. Or Write a small application before, that just extracts the values. Everything after "=" in each line.
0

You can make a heap dump of your application via jvisualvm, it will save all present in memory String instances. The result will be stored in .hprof file, see How do I analyze a .hprof file?

1 Comment

Tricky, but what if not all strings are loaded? And German and English strings (English from the JDK classes) would be mixed.
0

You can use regular expressions, like in this question: shell: extract string from source code

But probably the better way would be to configure the spell checker of your IDE.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.