User:RolandOfGilead/Java/ColorReplacer

import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException;

public class ColorReplacer {

public static void main(String[] args) throws IOException { String inputLine; BufferedReader in = new BufferedReader(new FileReader("in.txt")); FileWriter out = new FileWriter("out.txt");

String prof[] = {"W", "R", "Mo", "N", "Me", "E", "A", "Rt", "P", "D", "X"}; String dark[] = {"ea3", "5a0", "44b", "0a5", "80a", "b33", "a08", "0aa", "960", "77c", "666"}; String light[] = {"ff8", "cf9", "acf", "9fc", "daf", "fbb", "fce", "bff", "fc9", "ddf", "ddd"}; String darkOld[] = {"eeaa33", "55aa00", "4444bb", "00aa55", "8800aa", "bb3333", "aa0088", "00aaaa", "996600", "7777cc", "666666"}; String lightOld[] = {"ffff88", "ccff99", "aaccff", "99ffcc", "ddaaff", "ffbbbb", "ffccee", "bbffff", "ffcc99", "ddddff", "dddddd"}; int profLength = prof.length; int templatesAdded=0; int templatesRemoved=0; while((inputLine=in.readLine)!=null) { for(int i=0; i!=profLength; ++i) { if(inputLine.toLowerCase.contains("#" + darkOld[i])) { ++templatesAdded; int index = inputLine.toLowerCase.indexOf("#" + darkOld[i]); inputLine=inputLine.replaceAll(inputLine.substring(index, index+darkOld[i].length+1), ""); }				if(inputLine.toLowerCase.contains("#" + lightOld[i])) { ++templatesAdded; int index = inputLine.toLowerCase.indexOf("#" + lightOld[i]); inputLine=inputLine.replaceAll(inputLine.substring(index, index+lightOld[i].length+1), ""); }				if(inputLine.toLowerCase.contains("#" + dark[i])) { ++templatesAdded; int index = inputLine.toLowerCase.indexOf("#" + dark[i]); inputLine=inputLine.replaceAll(inputLine.substring(index, index+dark[i].length+1), ""); }				if(inputLine.toLowerCase.contains("#" + light[i])) { ++templatesAdded; int index = inputLine.toLowerCase.indexOf("#" + light[i]); inputLine=inputLine.replaceAll(inputLine.substring(index, index+light[i].length+1), ""); }			}			if(inputLine.contains("bgcolor={{")) { inputLine = inputLine.replaceAll("bgcolor{{\\s*=\\s*", "style=\"background:{{");				inputLine = inputLine.replace("}}", "}}\""); } //			System.out.println(inputLine); out.append(inputLine + "\n"); }		System.out.println("Templates added: " + templatesAdded); System.out.println("Templates removed: " + templatesRemoved); in.close; out.close; }

}