The best way to do it is to introduce a delimiter. This will become part of your protocol.
When you're sending the files, you send the data. When there are no more bytes to sends, the client will send an END_OF_MESSAGE
value to the server, indicating that there is no more data to send, then in your code, you've got something like:
String END_OF_MESSAGE = "ENDOFMESSAGE";
if(input.equals(END_OF_MESSAGE)) {
// You know the client has finished their transmission.
}
NOTE: I would make the value of END_OF_MESSAGE
far more complex than that. This is simply for demonstration purposes.
EDIT
As JB Nizet suggested, another option is to send the length of the file before anything else. That way the server knows when the transmission is finished when the amount of transferred bytes are equal to, or greater than, the pre-set size.