Cod sursa(job #1358648)

Utilizator RoxanaCptCapitanu Roxana - Steliana RoxanaCpt Data 24 februarie 2015 18:43:08
Problema Convertor Scor 0
Compilator java Status done
Runda rosedu_cdl_2015 Marime 1.72 kb
import java.io.*;
import java.util.*;
import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Roxana Capitanu
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
         String line1 = null, line2 = null;
         //HashMap<String,ArrayList> dict = new HashMap
      try{
         // open input stream test.txt for reading purpose.
         BufferedReader br;
         br = new BufferedReader(new FileReader("convertor.in"));
         BufferedWriter bw = new BufferedWriter(new FileWriter("convertor.out"));
         while ((line1 = br.readLine()).startsWith("}") == false) {
             if (line1.startsWith("\""))
                bw.write(line1.split(":")[0].split("\"")[1] + ",");
         }   
         bw.newLine();
         br.close();
         br = new BufferedReader(new FileReader("input.txt"));
         while ((line2 = br.readLine()) != null){
              if (line2.startsWith("\"")){
                  if (line2.split(":")[1].split("\"").length > 1)
                    bw.write(line2.split(":")[1].split("\"")[1] + ",");
                  else
                     bw.write(line2.split(":")[1].split(" ")[1].replaceAll(",","") + ",");
              }
                  
                  
              if (line2.startsWith("}"))
                  bw.newLine();
         }
         br.close();
        bw.close();
             
      }catch(Exception e){
         e.printStackTrace();
      }
   
    }
    
}