Cod sursa(job #1359587)

Utilizator RoxanaCptCapitanu Roxana - Steliana RoxanaCpt Data 24 februarie 2015 23:47:34
Problema Convertor Scor 0
Compilator java Status done
Runda rosedu_cdl_2015 Marime 1.84 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) throws IOException {
         String allText = null, line;
        String head;
        String list[];
         //HashMap<String,ArrayList> dict = new HashMap
         // open input stream test.txt for reading purpose.
         BufferedReader br;
         Scanner sr = new Scanner(new File("convertor.in"));
         
        // br = new BufferedReader(new FileReader("convertor.in"));
         BufferedWriter bw = new BufferedWriter(new FileWriter("convertor.out"));
        /* while ((line = br.readLine()) != null){
             allText += line;
              }
                */
          while (sr.hasNextLine()) {
              allText += sr.nextLine();
        }
       
          for (String s : allText.split("}")[0].split(","))
              bw.write(s.split(":")[0].split("\"")[1] + ",");
          bw.newLine();
          
          for (String str : allText.split("}")){
            for (String s : str.split(","))
                if (s.split(":").length > 1)
                {
                   if (s.split(":")[1].split("\"").length > 1)
                    bw.write(s.split(":")[1].split("\"")[1] + ",");
                     else
                     bw.write(s.split(":")[1].split(" ")[1].replaceAll(",","") + ","); 
                }
                bw.newLine();
          } 
            sr.close();
            bw.close();
             
      
    }
    
}