package ru.szhernovoy.treads1;

import java.io.*;

/**
 * Created by szhernovoy on 08.10.2016.
 */
public class CounterValuesText {


    /** path to directory with file */
    private final String PATH;
    /**Object for agregate string from file */
    private final StringBuilder builder;

    public CounterValuesText(final String path){
          this.PATH = path;
          this.builder = new StringBuilder();

    }

    /**
     * Read file and get string from file
     * @param fileName
     * @return
     */
    public String readTxtFile(String fileName){
        String fullName  = String.format("%s%s%s",this.PATH, File.separator,fileName);
        File file = new File(fullName);

        if(file.exists() && file.canRead() && file.isFile()){
            try(BufferedReader in = new BufferedReader(new FileReader(fullName))){
                String next = null;
                while((next = in.readLine()) != null){
                    builder.append(String.format("%s\n",next));
                }
            } catch (FileNotFoundException e) {
                System.out.println("File not exist");
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return this.builder.toString();
    }



    public static void main(String[] args) {
        CounterValuesText obj = new CounterValuesText("d:\\Test");
        String text = obj.readTxtFile("primer.txt");

        new Thread(new TokenCounter(true,text)).start();
        new Thread(new TokenCounter(false,text)).start();

    }


}

@@ -1298,24 +1298,59 @@
 g%5B%5D args) %7B%0A
+%0A%0A        if(args.length %3E 0)%7B%0A    
         Coun
@@ -1395,21 +1395,22 @@
 ext(
-%22d:%5C%5CTest%22);%0A
+args%5B0%5D);%0A    
     
@@ -1447,24 +1447,23 @@
 ile(
-%22primer.txt%22);%0A%0A
+args%5B1%5D);%0A%0A    
     
@@ -1511,24 +1511,28 @@
 )).start();%0A
+    
         new 
@@ -1573,23 +1573,34 @@
 )).start();%0A
+        %7D%0A%0A
 %0A    %7D%0A%0A%0A%7D%0A

update treads exc1