package csci599;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;

public class JSONGenerator
{
    static int noOfMIMETypes=15;
    static int charSetSize=256;
    
    public static String generateJSON(HashMap<String,ArrayList<Double>> fingerprint,HashMap<String,ArrayList<Double>> correlationStrengths)
    {
        String json="{";
        for(Object MIMEType:fingerprint.keySet())
        {
            json=json+"\""+MIMEType+"\": ";
            json=json+"{";
            json=json+"\"BFD\": ";
            json=json+"[";
            Iterator i1=fingerprint.get(MIMEType).iterator();
            while(i1.hasNext())
                json=json+i1.next()+",";
            json=json.substring(0, json.length()-1);
            json=json+"],";
            json=json+"\"CS\": ";
            json=json+"[";
            Iterator i2=correlationStrengths.get(MIMEType).iterator();
            while(i2.hasNext())
                json=json+i2.next()+",";
            json=json.substring(0, json.length()-1);
            json=json+"]";
            json=json+"},";
        }
        json=json.substring(0, json.length()-1);
        json=json+"}";
        return json;
    }
    
    public static double[][] getJSONFingerptint(String filePath) throws FileNotFoundException
    {
        double[][] fingerprint=new double[noOfMIMETypes][charSetSize];
        FileInputStream in = new FileInputStream(filePath);
        
        return fingerprint;
    }
}

@@ -13,16 +13,48 @@
 599;%0D%0A%0D%0A
+import java.io.BufferedReader;%0D%0A
 import j
@@ -117,16 +117,73 @@
 ption;%0D%0A
+import java.io.FileReader;%0D%0Aimport java.io.IOException;%0D%0A
 import j
@@ -1327,33 +1327,33 @@
 , json.length()-
-1
+2
 );%0D%0A        json
@@ -1492,16 +1492,29 @@
 xception
+, IOException
 %0D%0A    %7B%0D
@@ -1598,69 +1598,437 @@
     
-FileInputStream in = new 
+BufferedReader br=new BufferedReader(new FileReader(filePath));%0D%0A        String input=%22%22,inputFile=%22%22;%0D%0A        while((input=br.readLine())!=null)%0D%0A        %7B%0D%0A            inputFile=input
 File
-I
++i
 nput
-Stream(filePath);%0D%0A        
+;%0D%0A        %7D%0D%0A        int i=0,j=0;%0D%0A        String%5B%5D MIMETypes=inputFile.split(%22%7D,%22);%0D%0A        MIMETypes%5B0%5D=MIMETypes%5B0%5D.substring(1, MIMETypes%5B0%5D.length());%0D%0A        MIMETypes%5B14%5D=MIMETypes%5B14%5D.substring(0,MIMETypes%5B14%5D.length()-1);
 %0D%0A  

change in JSONGenerator