title: How to return to the beginning of a Bufferedreader?
body: <p>This is my code:    </p>
  
  <pre><code>public int Part1(BufferedReader reader) throws IOException{
          reader.mark(0);
          int counter1 = 0;
          String z;
          while((z = reader.readLine()) != null){
              counter1 = counter1 + z.length();
          }
          reader.reset();   // this is the error line
          return counter1;
      }
  </code></pre>
  
  <p>It is a  code to count the number of characters in a file. I have other algorithm to run in the same program which requires the BufferedReader to return to the beginning of a file. I looked at another answer on StackOverFlow and was trying to use the mark() and reset() method. However, there is a run time error:</p>
  
  <p>Exception in thread "main" java.io.IOException: Stream not marked
       at java.io.BufferedReader.reset(Unknown Source)</p>
  
  <p>What is the problem here?</p>