Fix the Javadoc for the method sendCommand
Check the read() return value
Use flip instead of rewind