title: How to read a file byte by byte using BufferReader class in java
body: <p>I want to read my file which is a large one byte by byte and i currently using this class for reading the file:</p>
  
  <pre><code>   public class File {
     public byte[] readingTheFile() throws IOException {
  
  
              FileReader in = new FileReader("/Users/user/Desktop/altiy.pdf");
  
                    BufferedReader br = new BufferedReader(in);
  
                  String line;
                 while ((line = br.readLine()) != null) {
                     System.out.println(line);
  
                  }
  
            in.close();
  
        return null;
  
        }
   } //close class
  </code></pre>
  
  <p>Now in my main class where my main method is i am trying to read the file and then try to pass it as parameter to another method of another class like below:</p>
  
  <pre><code> public class myMainClass {
  
    // some fields here
   File f = new File ();
  
     public static void main (String [] a) {
  
      try {
  
              byte[] secret = five.readingTheFile();  // We call the method which read the file
  
  
             byte[][] shar = one.calculateThresholdScheme(secret, n,k);
  
  // some other code here . Note n and k i put their values from Eclipse
  
        }  catch (IOException e) {
  
              e.printStackTrace();
  
                     } // close catch 
  
              } // close else
  
         } // close main
  
     } // close class
  </code></pre>
  
  <p>Now in my class where calculateThresholdScheme is</p>
  
  <pre><code>   public class performAlgorithm {
  
   // some fields here
  
        protected  byte[][] calculateThresholdScheme(byte[] secret, int n, int k) {
  
      if (secret == null)
          throw new IllegalArgumentException("null secret"); 
  
     // a lot of other codes below.
  </code></pre>
  
  <p>But my execution stops as soon as i throw this IllegalArgumentException("null secret"); which means my file is not yet readable. I am wondering what is going wrong here but i am still not figure it out</p>