Wednesday, May 29, 2013

Java Template

import java.util.Scanner;
import java.util.Formatter;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;

import java.util.ArrayList;
public class XXXXXX{
   
    /**
     * @param args the command line arguments
     */
    public static void main (String [] args) throws IOException {
       
       
        Scanner in = new Scanner(new File("./src/input.txt"));        // file input
        Formatter out = new Formatter(new File("./src/output.txt"));  // file output
       
        ArrayList<Integer> a = new ArrayList<Integer>();
        while(in.hasNext()){
            a.add(in.nextInt());
        }
        out.format("%s\n", a.toString());  // format() has the same syntax as printf()
       
        out.close();    // flush the output and close the output file
        System.exit(0); // likely needed in USACO
    }
}

No comments:

Post a Comment