Because a FileInputStream needs a real file to be
instantiated, the corresponding mock object also needs such
a file. For this reason, a KNOWN_FILE static member is
used, it is specified as C:/autoexec.bat
It is obvious that this only works on Windows, resulting in a
FileNotFound exception. If this public static member would
have been changeable, no problem, but it happens to be
final.
A better approach is to create a temp file and make sure it
is deleted upon shutdown of the VM.
Logged In: NO
An alternative would be to simply pass a FileDescriptor to
the super constructor instead of creating a temp file. This
should work platform independently:
private MockFileInputStream() {
// Unfortunately as there is no interface we have to
call the supertype,
// which requires a file.
super(new FileDescriptor());
}
Can anyone integrate this into the current code?
Regards,
Florian.