Question: I've made a GUI and a button.  

My code looks like this:

```
private void jButtonSubmitActionPerformed(java.awt.event.ActionEvent evt) {
try {
  Scanner scan = new Scanner(new File("persontest.txt"));
  while(scan.hasNext()) {
    System.out.println(scan.nextLine());
  }
} catch (FileNotFoundException ex) {
  System.out.println("File not found" + ex.getMessage());
} catch (Exception e) {
  System.out.println("Some error" + e.getMessage());
}

```

persontest.txt contains the following text: 

> 
> 1. What do I contribute with when working in team work:  
> 
>  a. I come up with new ideas  
> 
>  b. I follow-up on things because I'm basically
>  thorough  
> 
>  c. I assess what is realistic and workable  
> 
>  d. I advocate alternative approaches objectively and unbiased
> 
> 
> 

When trying to run I get "Some error No line found"  

I tried removing all special characters from the text and I could read it, so I tried adding "UTF-8" to my scanner in this manner. 

```
Scanner scan = new Scanner(new File("persontest.txt"), "UTF-8");   

```

However this does not seem to do anything. I still get "No line found".  

If this question has been asked before excuse me, I did a thorough search, but I either could not comprehend the question asked or the answer provided in context to my problem.  

I changed my scanner to bufferedreader per Troubleshoot and Harshas example and it will now read the text even with special chars, however it won't display them correctly. I just get square boxes. It's a minor problem.

Answer: 
If persontest.txt is in classpath (i.e. inside jar or source folder) you can use:

```
YourClass.class.getClassloader().getResourceAsStream("persontest.txt")

```
You could simply do this using 

```
    try {

        String line;

        BufferedReader br = new BufferedReader(new FileReader("persontest.txt"));

        while ((line = br.readLine()) != null) {
            System.out.println(line);
        }

    } catch (IOException e) {
        e.printStackTrace();
    } 

```

if you need to do it with a Scanner you can try using 

```
Scanner reader = new Scanner(new FileInputStream("persontest.txt");

```