Is it possible not to extract this into a separate file and somehow read it in memory? Maybe in a giant string or something else?
Yes of course.
Just replace the code in the inner loop that opens the files and writes them with the code that writes to ByteArrayOutputStream... or a series of such threads.
, TAR (, ), / . , , . . ( , /, ... .)
, , ... , .