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.

Sotirios Delimanolis
  • 274,122
  • 60
  • 696
  • 724
Jakob Alexander Eichler
  • 2,988
  • 3
  • 33
  • 49
  • Do you want to do that with Java? I would use Perl to read the .java files and search for regexes in the file – Bizmarck Nov 05 '13 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? – Axel Nov 05 '13 at 15:10

3 Answers3

1

You could use properties files

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

Ross Drew
  • 8,163
  • 2
  • 41
  • 53
  • 1
    if German is the only supported language, then it seems overkill to add property files only for spell checking. – lbalazscs Nov 05 '13 at 15:57
  • Leaves you with the nice side effects of being able to internationalise very easily and reuse text though. – Ross Drew Nov 06 '13 at 16:08
  • Copy and paste the properties file into MsOffice. Or Write a small application before, that just extracts the values. Everything after "=" in each line. – Stimpson Cat Aug 05 '14 at 23:28
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?

Community
  • 1
  • 1
Yurii Shylov
  • 1,219
  • 1
  • 10
  • 19
  • Tricky, but what if not all strings are loaded? And German and English strings (English from the JDK classes) would be mixed. – lbalazscs Nov 05 '13 at 15:58
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.

Community
  • 1
  • 1
lbalazscs
  • 17,474
  • 7
  • 42
  • 50