I need to read ~50 files on every server start and place each text file\'s representation into memory. Each text file will have its own string (which is the best type to use
The most efficient way is:
File.length())new InputStreamReader (new FileInputStream(file), encoding) to readnew String(buffer)If you need to search&replace once at startup, use String.replaceAll().
If you need to do it repeatedly, you may consider using StringBuilder. It has no replaceAll() but you can use it to manipulate the character array in place (-> no allocation of memory).
That said:
There is no reason to waste a lot of time into making this code run fast if it takes just 0.1s to execute.
If you still have a performance problem, consider to put all the text files into a JAR, add it into the classpath and use Class.getResourceAsStream() to read the files. Loading things from the Java classpath is highly optimized.