A
A
Alexander Markelov2022-04-20 13:54:38
Java
Alexander Markelov, 2022-04-20 13:54:38

Why is the StrProcess object not being created?

When I try to compile, it gives errors, please tell me what is the problem:
625fe66b09ded192293967.png
code Main

package lab3;
import java.util.ArrayList;

public class Main
{
  public static void main(String[] args)
  {
    String query1 = "query1.txt";
    String query2 = "query2.txt";
    String query4 = "query4.txt";

    String regex1 = "*69$";
    String regex2 = "SPORT";
    String regex4 = "*1{1}[0-9]{3}$";

    StrProcess condition1 = new StrProcess(query1, regex1);
    StrProcess condition2 = new StrProcess(query2, regex2);
    StrProcess condition3 = new StrProcess(query4, regex4);

    ArrayList<String> result1 = condition1.GetAll();
    ArrayList<String> result2 = condition2.GetAll();
    ArrayList<String> result3 = condition3.GetAll();

  }
}

code StrProcess.java
package lab3;

import java.io.File;
import java.util.regex.Pattern;
import java.util.Scanner;
import java.util.ArrayList;
import java.io.FileNotFoundException;

public class StrProcess
{
  private String filename, regex;
    ArrayList<String> Str = new ArrayList<String>();

  StrProcess(String filename, String regex)
  {
    try
    {
    File query = new File(filename);
    Scanner reader = new Scanner(query);
    while(reader.hasNextLine())
    {
      if(Pattern.matches(regex, reader.nextLine()))
      {
        Str.add(reader.nextLine());
      }
    }
    }
    catch(FileNotFoundException e)
    {
      System.out.println("File Not Found");
    }

  }

  private void Sort()
  {

  }

  public ArrayList<String> GetAll()
  {
    return(Str);
  }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Voland69, 2022-04-20
@lucky_bastard

Main does not see the StrProcess type, show how you compiled it?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question