Skip to content

Instantly share code, notes, and snippets.

@Ricket
Created April 28, 2011 04:15
Show Gist options
  • Save Ricket/945790 to your computer and use it in GitHub Desktop.
Save Ricket/945790 to your computer and use it in GitHub Desktop.
Template for programming competition Java program
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.UnknownHostException;
public class CompetitionEntry {
public static void main(String[] args) {
try {
if(InetAddress.getLocalHost().getHostName().equals("ricky-mbp")) {
try {
System.setIn(new FileInputStream(new File("/Users/ricky/Desktop/input.txt")));
} catch (FileNotFoundException e1) {
System.out.println("Input file not found");
System.exit(1);
}
}
} catch (UnknownHostException e1) {
}
InputStreamReader converter = new InputStreamReader(System.in);
BufferedReader in = new BufferedReader(converter);
// in.readLine();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment