I am testing an ObjectInputStream
in Java. When I include the if statement, I get an EOF error. How do I properly test the object coming into the stream? The input stream object is of type byte[] array
.
if (ObjectInputStream.readObject() instanceof byte[]) {
// what to get the new file
System.out.println("Getting File");
fileFromServer = new File("/Users/joshuataylor/git/swd_jtylor/oral_exam2/27-13_FileRetrieve_Easy/src/output.txt");
byte[] fileContent = (byte[]) ObjectInputStream.readObject();
System.out.println(fileContent.length);
Files.write(fileFromServer.toPath(), fileContent);
ObjectOutputStream.flush();
message = "End Connection";
System.out.println("eof");
}