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 Answer 1

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\$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.