Skip to content

Instantly share code, notes, and snippets.

@k163377
Last active August 13, 2018 11:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save k163377/59110c5007c7e1f15d2c18969fbb19e7 to your computer and use it in GitHub Desktop.
Save k163377/59110c5007c7e1f15d2c18969fbb19e7 to your computer and use it in GitHub Desktop.
import java.io.BufferedReader
import java.io.FileNotFoundException
import java.io.FileReader
val prefix: String = "<color name="
val middle: String = ">"
val suffix: String = "</color>"
fun main(args:Array<String>) {
try{
val br = BufferedReader(FileReader("C:\\Users\\wrongwrong\\IdeaProjects\\MakeLangColorXML\\src\\languages.json"))
var temp: String? = br.readLine()
var color: String
while (temp != null){
if(temp.contains("\": {")){
//言語名、xmlでは使えない文字は_で置換
color = prefix +
temp.split(':')[0]
.substring(2)
.replace(' ', '_')
.replace('+', '_')
.replace('#', '_')
.replace('-', '_')
.replace('\'', '_') +
middle
temp = br.readLine()
while(true){
if(temp!!.contains("color")) {
color += temp.split(": \"")[1].split("\",")[0].split('\"')[0] + suffix
println(color)
break
}else if(temp == " },") break
temp = br.readLine()
}
}
temp = br.readLine()
}
}catch (e: FileNotFoundException){
println(e)
}
}
@k163377
Copy link
Author

k163377 commented Aug 13, 2018

色入ってない場合があって死ぬので修正

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment