Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package com.shawon.strings;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.util.Scanner;
- /**
- *
- * @author shawonmajid
- */
- public class StringTest {
- public static void main(String[] args) {
- Scanner in = null;
- try {
- File input = new File("input.txt");
- in = new Scanner(input);
- } catch (FileNotFoundException ex) {
- System.out.println("Couldn't Open file");
- }
- int ans = 0;
- while(in.hasNext()){
- String cur = in.next();
- if(!cur.equals("end")){
- ans += Integer.parseInt(cur);
- }
- }
- System.out.println(ans);
- }
- }
Add Comment
Please, Sign In to add comment