Using single StringBuilder - throws OutofmemeoryException
问题 do like the below code, to read each line and perform a concatenation based on an input list listValues. BufferedReader br = null; StringBuilder sb = new StringBuilder(""); InputStream in = new FileInputStream(new File(file)); br = new BufferedReader(new InputStreamReader(in), 102400); for (String input; (input= br.readLine()) != null;) { for (int i = 0; i < listValues.size(); i++) { sb.append(input.substring(1, 5)); } map.put(sb.toString(), someOtherValue); sb.delete(0, sb.length()); } Using