Read File That Is String -> Integer (Assigning Value In Code)

Hello Team,
I have an issue with reading a string from a "file" called file.txt and turning it into a integer value.

Of you look below - i'm reading data from a file called file.txt and storing the data into an arraylist.

The first line in that text file says
priority  = 5;
It must say this on the first line. (it is a configuration file basically)

What i need to do in the code is make priority *the variable* equal to 5, but it come in as a string.
The data is in an arraylist  - so if try to print sl.get(0); I see that it's captured "priority = 5" as a string, but what i don't need
is the "priority =" part and the semi colon at the end. Just the 5, how do I get ?

See code below.
Thanks kindly



============================================================
class MyThreadGroupFactory {
//Thread Group Object which will set the maximum priority for all even threads.

    private ThreadGroup threadGroup = null;
    private static MyThreadGroupFactory instance = new MyThreadGroupFactory();
    int priority = 1;


    private MyThreadGroupFactory()
    {
          
    threadGroup = new ThreadGroup("Event Group");
       
    StringList sl = new StringList();
      sl.read("file.txt");
      
      //System.out.println(sl.get(0));


    threadGroup.setMaxPriority(priority); //<============================ "SETTING PRIORITY HERE"
    }
   
    public static ThreadGroup getThreadGroup()
    {
        return instance.threadGroup;
    }
}

class StringList extends ArrayList {


//Constructor for the StringList object


  public StringList() {
    super();
  }

  public void read(InputStream in) {
    read(new InputStreamReader(in));
  }


  public void read(Reader r) {
    String line = null;
    BufferedReader in = null;
    try {
      in = new BufferedReader(r);
      while ((line = in.readLine()) != null) {
        add(line);
      }
    }
    catch (IOException e) {
      e.printStackTrace();
    }
    finally {
      try {
        in.close();
      }
      catch (IOException e) {
        e.printStackTrace();
      }
    }

  }

  public void read(String fileName) {
    try {
      read(new FileReader(fileName));
    }
    catch(IOException e) {
      e.printStackTrace();
    }
  }

}
============================================================

pauldhadiallaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

petmagdyCommented:
easy, for example if ur file is a single line as u described contains only the line u mentioned then just try this:

 int periority = 0;
String line = sl.get(0);
String[] splited = line.split("[/s=;]");
if(splited.length > 1)
   periority = Integer.parseInt( splited[1].trim() );
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.