JustPaste.it

package javaproject2;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashSet;


public class pChecker {

private final comparingGUI cg;


pChecker(comparingGUI cg) {
        this.cg = cg;
    }

    public static long l1 = 0;
    public String[] placeToStart = new String[]{
        "[Device|EEP_FEATUREKOI_HFS_Max|Kostia]",
        "[Device|EEP_FEATUREKOI_HFS_Max|F17C FazitIdentificationString]",
        "[Device|EEP_FEATUREKOI_HFS_Max|F187 VW/AUDI Partnumber]",
        "[Device|EEP_FEATUREKOI_HFS_Max|F189 SW Number]",
        "[Device|EEP_FEATUREKOI_HFS_Max|F1A3 HW Version]",
        "[Device|EEP_FEATUREKOI_HFS_Max|F18C ECU Serialnumber]"};

    public String[] placeToFinish = new String[]{
        ";end of section [Device|EEP_FEATUREKOI_HFS_Max|Kostia]",
        ";end of section [Device|EEP_FEATUREKOI_HFS_Max|F17C FazitIdentificationString]",
        ";end of section [Device|EEP_FEATUREKOI_HFS_Max|F187 VW/AUDI Partnumber]",
        ";end of section [Device|EEP_FEATUREKOI_HFS_Max|F189 SW Number]",
        ";end of section [Device|EEP_FEATUREKOI_HFS_Max|F1A3 HW Version]",
        ";end of section [Device|EEP_FEATUREKOI_HFS_Max|F18C ECU Serialnumber]"};

    public ArrayList<String> importantName = new ArrayList<String>();
    public ArrayList<String> importantNumber = new ArrayList<String>();
    public LinkedHashSet<String> LHS = new LinkedHashSet<String>();
    public

    String placeFinder(File currentFileX, String line,String Hex, String cutName) throws FileNotFoundException, IOException {

        try {

         BufferedReader reader = new BufferedReader(new FileReader(currentFileX));

         line = reader.readLine();
        
         for (int i=0;i<placeToStart.length;i++){

          do {//read line and do following until placeToFinish is found

           if (line.equals(placeToStart[i])) { //IF line is placeToStart then do following
              
             do {// read line and 'do following' until placeToFinish is found

               if (line.contains("Name")&& line.contains("_")) {
                 String basicName = line;
                 cutName = basicName.split("=")[1].trim();//get substring after '='
                 cutName = cutName.substring(0,cutName.lastIndexOf("_"));//removes '_'?
                  
                 importantName.add(i, (cutName + " = "));//add to element i
                  System.out.println("Line reads: " + basicName);
                  System.out.println("Part: " + cutName);
                 
               do{                  
                  if (line.contains("Value")) {
                        Hex = line.split("=")[1].trim();//get substring after '='
                        importantNumber.add(i, Hex);//get substring after '='
                  System.out.println("Value: " + Hex);                       
                    }//end if                 
                }while(!"Value".contains(line = reader.readLine()));
               while (!placeToFinish[i].equals(line = reader.readLine()));
              
               }else   
                if(line.contains("Name")) {
                  String basicName = line;
                  cutName = basicName.split("=")[1].trim();//get substring after '='
                    
                 importantName.add(i, (cutName + " = "));//get substring after '='
                 System.out.println("Line reads: " + basicName);
                 System.out.println("Part: " + cutName);
                 System.out.println("Number: " + importantNumber.indexOf(i) + "\n");
                
                 do{ 
                  if (line.contains("Value")) {
                     Hex = line.split("=")[1].trim();//get substring after '='
                     importantNumber.add(i, Hex);//get substring after '='
                  }//end if                   
                }while (!"Value".contains(line = reader.readLine()));
                while (!placeToFinish[i].equals(line = reader.readLine()));
             }//end if
              
          } while (!placeToFinish[i].equals(line = reader.readLine()));
        }
    } while (!placeToFinish[i].equals(line = reader.readLine()));
   }
   } catch (IOException e) {
      System.out.println("IO Exception: Could not read file!\n");
   }
     return null;
   }
}