0
\$\begingroup\$

I'm reading a text file from Gdx.files.internal in LibGdx. This is essentially streaming a file from a compressed Jar file so random access is not possible.

I want to search through the text file line by line until I get to the bit I want. That's easy enough, but I want to do it without generating loads of Strings and leaving lots for the GC to clean up.

Whats the best way of scanning through the file without creating object garbage?

\$\endgroup\$
1
\$\begingroup\$

It sounds like you don't want to create a whole bunch of String instances for the GC to clean up, so how about using one or more char[] to hold the text file data?

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.