I want to read my file which is a large one byte by byte and i currently using this class for reading the file:
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
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:
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
Now in my class where calculateThresholdScheme is
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.
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
readingTheFile()returns null no matter what? By perhaps, I mean that's definitely what it is.BufferedReaderis not for reading bytes, it's for reading text. UseInputStream.