code: private void sendStream(InputStream in) {
          new Thread(() -> {
              try {
                  con.sendData(in);
                  con.sendResponse(226, "File sent!");
              } catch(ResponseException ex) {
                  con.sendResponse(ex.getCode(), ex.getMessage());
              } catch(Exception ex) {
                  con.sendResponse(451, ex.getMessage());
              }
          }).start();
      }
docs: Sends a stream asynchronously, sending a response after it's done
  @param in The stream