Also, how you know it read the book, and not a summary of it, of which there are loads on the internet?
In the case of ChatGPT, it’s hard to tell. OpenAI won’t even reveal what their training dataset was.
Researchers have done some tests to tease this out, and they’re pretty confident that it has read quite a few books and memorized them verbatim. See one of my favorite papers in a while, Speak, Memory: An Archaeology of Books Known to ChatGPT/GPT-4.