@@ -0,0 +1,1862 @@
+package ru.job4j.cyclic;%0A%0Aimport java.io.IOException;%0Aimport java.nio.file.Files;%0Aimport java.nio.file.Paths;%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0A/**%0A * Created on 11.09.17%0A * Check cyclic entries in file.%0A * @author Wamdue%0A * @version 1.0%0A */%0Apublic class CheckCyclic %7B%0A    /**%0A     * file path%0A     */%0A    private String filePath;%0A%0A    /**%0A     * Main constructor.%0A     * @param filePath source file.%0A     */%0A    public CheckCyclic(String filePath) %7B%0A        this.filePath = filePath;%0A    %7D%0A%0A    /**%0A     * Checking file for cyclic entries.%0A     * @return list of cyclic entries or empty list, if not found.%0A     */%0A    public List%3CString%3E checkCyclic() %7B%0A        List%3CString%3E list = new ArrayList%3C%3E();%0A        try %7B%0A            StringBuilder builder = new StringBuilder();%0A            List%3CString%3E allLines = Files.readAllLines(Paths.get(filePath));%0A            for (String line : allLines) %7B%0A                if (builder.length() == 0) %7B%0A                    builder.append(line);%0A                %7D else %7B%0A                    if (line.equals(builder.reverse().toString())) %7B%0A                        builder.insert(0, line.charAt(line.length() - 1) + %22 %22);%0A                        list.add(builder.toString());%0A                        builder.delete(0, builder.length());%0A                    %7D else %7B%0A                        builder.delete(0, builder.length());%0A                        builder.append(line);%0A                    %7D%0A                %7D%0A            %7D%0A        %7D catch (IOException e) %7B%0A            e.printStackTrace();%0A        %7D%0A        return list;%0A    %7D%0A%0A    /**%0A     * Main void.%0A     * @param args - first parameter is file path.%0A     */%0A    public static void main(String%5B%5D args) %7B%0A        CheckCyclic cc = new CheckCyclic(args%5B0%5D);%0A        for (String s : cc.checkCyclic()) %7B%0A            System.out.println(s);%0A        %7D%0A    %7D%0A%7D%0A

Check cyclic in file, task #24389