-
-
Save owniz/24e732c82d22f4325c0b29ab361881d2 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(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment