I have a large text file(about 20 million lines) which has lines in the following format :
<string1>, <string2>
Now those strings may have trailing or leading whitespaces which I want to remove on reading the file.
I am currently using trim()
for this purpose but since String in Java is immutable, trim()
is creating a new object per trim operation.
This is leading to too much wastage of memory.
How can I do it better?