Last active
May 10, 2016 13:30
-
-
Save GrenderG/18c0d198ceeea4144f97 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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