Converting J2me projects to Android. Wanted to convert property files to the android xml so decided to cobble together a bit of Groovy
The property file is something like this:
##general strings
menu=Menu
stop=Stop
back=Back
wait=Wait
search=Search
bb.nextmess=Click spacebar for next Question
Make sure you stick the property file name on the command line ….
import groovy.xml.MarkupBuilder
def writer = new StringWriter()
def xml = new MarkupBuilder(writer)writer.append(’<?xml version=”1.0″ encoding=”utf-8″?>’)
xml.resources {
new File(args[0]).eachLine{line->
bits = line.tokenize(”=”)
try {
string(name:bits[0].trim(),bits[1].trim())} catch (Exception e) {
//exceptions pah!
}}
}
println writer.toString()
This give the output ….
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name='menu'>Menu</string>
<string name='stop'>Stop</string>
<string name='back'>Back</string>
<string name='wait'>Wait</string>
<string name='search'>Search</string>
<string name='bb.nextmess'>Click spacebar for next Question</string>
</resources>