Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- /**
- *
- * @author Админ
- */
- import java.io.*;
- public class NewClass {
- public static void main(String[] args) {
- if(args.length != 2) {
- System.out.println("Wrong input");
- return; //вариант1 и продолжить.
- }
- try {
- StreamTokenizer in = new StreamTokenizer(new FileInputStream(args[0]));
- in.nextToken();
- int length = (int)in.nval;
- double sum = 0.0; //не нужно созавать массив
- for(int i = 0; i < length; i++,in.nextToken())
- sum +=in.nval;
- PrintWriter out = new PrintWriter(new FileWriter(args[1]));
- out.print(sum);
- out.close();
- } catch(Exception exc) {
- System.out.println("" + exc);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement