Строка line.contains () не находит определенный символ - PullRequest
0 голосов
/ 27 августа 2018

Я пытаюсь обнаружить определенные символы в строке файла шага. Он не находит # 1331 в файле шага. Я использую line.contains (), чтобы найти символ. Программный код приведен ниже.

public class test {
    String line;
    BufferedReader buff;
    FileReader file;
    ArrayList<String> face_bound = new ArrayList<>();
    ArrayList<String> edge_curve = new ArrayList<>();
    int counterTest =0;

    public  test(String filename)
    {
        file  = null;
        try 
        {
            file = new FileReader(new File("test/"+filename+".STEP"));

        }

        catch (FileNotFoundException e) 
        {
            System.err.println("Could not read the step file");
            e.printStackTrace();
        }
        detectionTest();
    }

    public void detectionTest()
    {
        face_bound.add("#1427");
        face_bound.add("#1331");
        try 
        {
           buff = new BufferedReader(file);
            while(true)
            {
                line = buff.readLine();
                if(line.contains(face_bound.get(counterTest)) && line.contains("EDGE_LOOP"))
                {
                    System.out.println("TEST: "+line);
                    String[] currentLine = line.split(",");
                    String[] currentLine1 = currentLine[1].split(" ");
                    System.out.println("EDGE LOOP references:"+ currentLine1[2]);
                    edge_curve.add(currentLine1[2]+" ");
                    counterTest++;
                    if(counterTest==face_bound.size())
                    {
                        break;
                    }

                }

                if(line.contains("END-ISO-10303-21;"))
                {
                    break;
                }

            }
        }
        catch (IOException e) 
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

Выход: ТЕСТ: # 1427 = EDGE_LOOP ('НЕТ', (# 1853, # 18)); EDGE LOOP ссылки: # 1853

Но код должен обнаружить # 1331 и распечатать ссылку EDGE LOOP.

...