Skip to content

Instantly share code, notes, and snippets.

@moskyb
Last active May 27, 2016 02:08
Show Gist options
  • Save moskyb/49276883eb2c1af4bc565617423d3645 to your computer and use it in GitHub Desktop.
Save moskyb/49276883eb2c1af4bc565617423d3645 to your computer and use it in GitHub Desktop.
/**
* Looks for an existing transcript and reads it into an array if found.
* If the file doesn't exist it creates a new transcript.
*
* @param file File to read from
* @throws IOException
*/
public void readFile(File file) throws IOException {
Charset charset = Charset.forName("utf-8");
Arraylist<String> someList = new Arraylist<String>();
try {
BufferedReader reader = Files.newBufferedReader(Paths.get(file.getAbsolutePath()), charset);
String line;
while ((line = reader.readLine()) != null) {
someList.put(line);
}
} catch (IOException x) {
//File does not exist... not possible as user cannot select nothing from a fileChooser
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment