Pagini recente » Cod sursa (job #2902243) | Cod sursa (job #1334013) | Cod sursa (job #1226884) | Cod sursa (job #2515792) | Cod sursa (job #1350030)
import java.io.*;
import java.util.*;
@SuppressWarnings({ "rawtypes", "unchecked" })
public class Main {
static Hashtable hash = new Hashtable();
static int ok = 0;
public static void main(String[] args) throws IOException {
// String dir = System.getProperty("user.dir");
Scanner br = new Scanner(new FileInputStream("convertor.in"));
PrintWriter pw = new PrintWriter("convertor.out");
String s, aux;
int index, index2, nr = 0;
Vector val = new Vector();
while (br.hasNext()) {
s = br.nextLine();
String[] t = s.split(",");
for (int i = 0 ; i < t.length ; i++) {
if (ok == 0) {
if (t[i].matches("^.*[^a-zA-Z0-9 ].*$")) {
index = t[i].indexOf("\"");
index2 = t[i].indexOf("\"", index + 1);
aux = t[i].substring(index + 1, index2);
pw.print(aux + ",");
aux = t[i].substring(index2 + 1, t[i].length());
aux = aux.trim();
aux = aux.substring(1, aux.length());
aux = aux.trim();
if (aux.contains("\"")) {
index = aux.indexOf("\"");
index2 = aux.indexOf("\"", index + 1);
aux = aux.substring(index + 1, index2);
}
val.add(aux);
}
if (t[i].contains("}")) {
pw.println();
for (int j = 0 ; j < val.size() ; j++)
pw.print(val.get(j) + ",");
pw.println();
ok = 1;
}
}
else {
if (t[i].matches("^.*[^a-zA-Z0-9 ].*$")) {
index = t[i].indexOf("\"");
index2 = t[i].indexOf("\"", index + 1);
aux = t[i].substring(index + 1, index2);
aux = t[i].substring(index2 + 1, t[i].length());
aux = aux.trim();
aux = aux.substring(1, aux.length());
aux = aux.trim();
if (aux.contains("\"")) {
index = aux.indexOf("\"");
index2 = aux.indexOf("\"", index + 1);
aux = aux.substring(index + 1, index2);
}
if (nr == val.size()) {
nr = 0;
pw.println();
}
pw.print(aux + ",");
nr++;
}
}
}
}
br.close();
pw.close();
}
}