Skip to content

Instantly share code, notes, and snippets.

@GrenderG
Last active May 10, 2016 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save GrenderG/18c0d198ceeea4144f97 to your computer and use it in GitHub Desktop.
Save GrenderG/18c0d198ceeea4144f97 to your computer and use it in GitHub Desktop.
import java.io.IOException;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import java.util.ArrayList;
public class GCIOTemplate {
public static List<String> readFile(String path, String fileName) throws IOException {
Path inFilePath = Paths.get(path, fileName);
Charset charset = Charset.forName("ISO-8859-1");
return Files.readAllLines(inFilePath, charset);
}
public static void writeFile(String filePath, ArrayList<String> inputToWrite) throws IOException {
BufferedWriter bw = new BufferedWriter(new FileWriter(filePath));
for (int i = 0; i < inputToWrite.size(); i++) {
bw.write("Case #" + (i + 1) + ": " + inputToWrite.get(i));
if (i < inputToWrite.size() - 1)
bw.newLine();
}
bw.close();
}
}
import java.util.*;
import java.io.*;
public class GCJTemplate {
public static void main(String[] args) {
Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in))); // MY_PROGRAM < large_input.txt > large_output.txt
int testCases = in.nextInt();
for (int i = 1; i <= testCases; i++) {
int n = in.nextInt();
System.out.println("Case #" + i + ": " + n);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment