My codes are
public void sendFile () throws IOException {
DataOutputStream dataOutputStream = new DataOutputStream(socket.getOutputStream());
byte[] buffer = new byte[4096];
FileInputStream fileInputStream = new FileInputStream("\"C:\\Users\\abdul\\Desktop\\Instructions.txt\"");
int bytes = fileInputStream.read(buffer,0,buffer.length);
dataOutputStream.write(buffer,0,bytes);
}
private void receiveFile() throws Exception{
DataInputStream dataInputStream = new DataInputStream(socket.getInputStream());
byte[] buffer = new byte[Integer.MAX_VALUE];
int bytes = dataInputStream.read(buffer,0,buffer.length);
FileOutputStream fileOutputStream = new FileOutputStream("Instructions.txt");
fileOutputStream.write(buffer,0,bytes);
}
I do not get an error but when I run my program, the output just spams null for the class using receiveFile. I just need to send a file from server to client.