Skip to content

Instantly share code, notes, and snippets.

@richashworth
Last active October 1, 2015 19:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richashworth/2043554 to your computer and use it in GitHub Desktop.
Save richashworth/2043554 to your computer and use it in GitHub Desktop.
Used as dependency in PowerMock Example
package com.richashworth.powermockexample;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.List;
import static com.google.common.io.Files.readLines;
public final class DataProvider {
public static List<String> getData() {
List<String> data = null;
try {
data = new DataProvider().readFile();
} catch (IOException e) {
e.printStackTrace();
}
return data;
}
private static List<String> readFile() throws IOException {
File file = new File("/some/path/to/file");
List<String> lines = readLines(file, Charset.forName("utf-8"));
return lines;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment