karen_beaudouin

XOG Using JAVA Method  (moved from Blog site to message board)

Discussion created by karen_beaudouin on Nov 29, 2011
Latest reply on Mar 11, 2013 by navzjoshi00
I have a solution to reduce the size XOG using the Java method.

public static void doClear(final File in) throws Exception {
final String newName = XOGClearLines.doTransformName(in);
BufferedReader br = null;
BufferedWriter bw = null;
String line = null;
StringBuilder buffer = new StringBuilder();

boolean pt = false;
boolean en = false;
boolean es = false;

try {
br = new BufferedReader(new InputStreamReader(new FileInputStream(in)));
bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(newName))));
do {
line = br.readLine();
if (line != null) {
if ((line.contains("<nls languageCode=\"cs\""))) {
continue;
}
if ((line.contains("<nls languageCode=\"da\""))) {
continue;
}
if ((line.contains("<nls languageCode=\"de\""))) {
continue;
}
if ((line.contains("<nls languageCode=\"fi\""))) {
continue;
}
if ((line.contains("<nls languageCode=\"fr\""))) {
continue;
}
if ((line.contains("<nls languageCode=\"it\""))) {
continue;
}
if ((line.contains("<nls languageCode=\"ko\""))) {
continue;
}
if ((line.contains("<nls languageCode=\"nl\""))) {
continue;
}
if ((line.contains("<nls languageCode=\"no\""))) {
continue;
}
if ((line.contains("<nls languageCode=\"pl\""))) {
continue;
}
if ((line.contains("<nls languageCode=\"ru\""))) {
continue;
}
if ((line.contains("<nls languageCode=\"sv\""))) {
continue;
}
if ((line.contains("<nls languageCode=\"tr\""))) {
continue;
}
if ((line.contains("<nls languageCode=\"zh\""))) {
continue;
}
if ((line.contains("<nls languageCode=\"hu\""))) {
continue;
}
if ((line.contains("<nls languageCode=\"ja\""))) {
continue;
}
if ((line.contains("<nls languageCode=\"zh_TW\""))) {
continue;
}
if (line != null && line.contains("<nls")) {
buffer.append(line);
while ((line != null) && !line.contains("/>")) {
line = br.readLine();
buffer.append(line);
}
line = "";
pt = buffer.toString().contains("languageCode=\"pt\"");
en = buffer.toString().contains("languageCode=\"en\"");
es = buffer.toString().contains("languageCode=\"es\"");
if (pt || en || es) {
line = buffer.toString();
}
buffer.setLength(0);
}
}
if (line != null) {
bw.write(line + "\r");
}
} while (line != null);
} finally {
closeFile(bw);
closeFile(br);
}
}

Outcomes