Java BufferedReader read one line
import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; public class Main { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new FileReader(new File("files/lines.txt"))); String lines = reader.readLine(); while (lines != null) { int currentSum = 0; for (int i = 0; i < lines.length(); i++) { currentSum += lines.charAt(i);//from w w w . j a v a 2 s . com } lines = reader.readLine(); System.out.println(currentSum); } reader.close(); } }