Stream closed on a ClassLoader input
Here is my code (yes, I know part of it isn't used anymore):
Quote:
public static boolean comparePasswords(String input) throws IOException{
String password = "";
String file = "src/password.spm";
FileInputStream passwordRead = new FileInputStream(file);
BufferedInputStream passwordBuffer = new BufferedInputStream(ClassLoader.getSystemResourceA sStream(file));
DataInputStream passwordInput = new DataInputStream(passwordBuffer);
while(passwordInput.available() != 0){ //<---- Here is the error
password = passwordInput.readLine();
}
if(encrypt(input).equals(password)){
return true;
}
else{
return false;
}
}
and my problem:
Quote:
Exception in thread "main" java.io.IOException: Stream closed
at java.io.BufferedInputStream.getInIfOpen(Unknown Source)
at java.io.BufferedInputStream.available(Unknown Source)
at java.io.FilterInputStream.available(Unknown Source)
at login.login.comparePasswords(login.java:29)
at login.login.main(login.java:73)
I don't close the stream anywhere, so I don't understand what it is whining about - can "ClassLoader.getSystemResourceAsStream(file)" not be used like that?