Finding specific text in txt file and storing it in String
<p>first I want to say that I'm beginer and that this is my first Java program. I'd like to make a program that will read text file, find specific line, and save it to my string variable.</p>

<p>So I want to find line that starts with "Dealt to ", and then in that line, copy everything after that till this char '[' and put it in my string variable. </p>

<p>So let's say that I have this line in my text file:
<strong>Dealt to My NickName [text]</strong>
I want to have a program that will find text "My Nickname" and put it in my string variable.</p>

<p>I'm trying to work with classes and trying to use setters and getters just to practice, please let me know how my code looks like and how I can improve it and make it work.</p>

<p>this is Main.java:</p>

<pre><code>import java.io.IOException;

public class Main {
    public static void main(String[] args) throws IOException{
        HandHistory hh1 = new HandHistory();
        String hero1 = null;

        hero1 = hh1.getHero();
        System.out.println(hero1);

    }
}
</code></pre>

<p>My HandHistory.java:</p>

<pre><code>import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class HandHistory {

    private String hero; 

    public HandHistory(){}

    public String getHero() throws IOException {
        FileReader in = new FileReader("G:/Java/workspace/HandHistory/src/File.txt");
        BufferedReader br = new BufferedReader(in);

        String line;
        while ((line = br.readLine()) != null) {
            if (line.contains("Dealt to ")){
                hero = line.substring(9,(line.indexOf("["))-1);

            }
        }                   
        return hero;
    }

    public void setHero(String hero){
        this.hero = hero;
    }
}
</code></pre>