Remove itemstack on inventorie

if i have the items what i want to remove how i can remove it in inventory ?

Inventory items = player.getInventory().query(item);
if (items.peek(numberOfItems).filter(stack -> stack.getQuantity() == numberOfItems).isPresent()) {
    items.poll(numberOfItems);
} else {
    // Not enough items
}