Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.FileNotFoundException;
- import java.io.FileReader;
- import java.io.IOException;
- import java.io.PrintWriter;
- public class TestIO {
- public static void main(String[] args){
- try {
- FileReader fr = new FileReader("olympic.txt");
- BufferedReader br = new BufferedReader(fr);
- PrintWriter pw = new PrintWriter("processed.txt");
- String s =br.readLine();
- int value=0;
- while(s!=null){
- String[] array = s.split(" ");
- for(int i=1;i<=3;i++){
- value+= Integer.parseInt(array[i]);
- System.out.println("Total value is : "+value);
- }
- pw.println(s+" "+"Total :"+value);
- value =0;
- System.out.println(s);
- s =br.readLine();
- }
- fr.close();
- pw.close();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement