Sum Lines in a text file
import java.io.*; public class SumLines { 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); }/* w ww.jav a2s .c om*/ lines = reader.readLine(); System.out.println(currentSum); } } }