@Test public void testReadFileIntoListNull() throws IOException { sfr = new SourceFileReader("non-existing-type"); List<String> actualList = sfr.readFileIntoList("any-filepath"); assertNull(actualList); }
public List<String> readFileIntoList(String filepath) throws IOException { if (type.contentEquals("local")) { List<String> lines = new ArrayList<>(); File file = new File(filepath); BufferedReader reader = new BufferedReader(new FileReader(file)); String line = null; while ((line = reader.readLine()) != null) { lines.add(line); } reader.close(); return lines; } else if (type.contentEquals("web")) { List<String> lines = new ArrayList<>(); URL url = new URL(filepath); BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream())); String line = null; while ((line = reader.readLine()) != null) { lines.add(line); } reader.close(); return lines; } else { return null; } }
SourceFileReader { public List<String> readFileIntoList(String filepath) throws IOException { if (type.contentEquals("local")) { List<String> lines = new ArrayList<>(); File file = new File(filepath); BufferedReader reader = new BufferedReader(new FileReader(file)); String line = null; while ((line = reader.readLine()) != null) { lines.add(line); } reader.close(); return lines; } else if (type.contentEquals("web")) { List<String> lines = new ArrayList<>(); URL url = new URL(filepath); BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream())); String line = null; while ((line = reader.readLine()) != null) { lines.add(line); } reader.close(); return lines; } else { return null; } } }
SourceFileReader { public List<String> readFileIntoList(String filepath) throws IOException { if (type.contentEquals("local")) { List<String> lines = new ArrayList<>(); File file = new File(filepath); BufferedReader reader = new BufferedReader(new FileReader(file)); String line = null; while ((line = reader.readLine()) != null) { lines.add(line); } reader.close(); return lines; } else if (type.contentEquals("web")) { List<String> lines = new ArrayList<>(); URL url = new URL(filepath); BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream())); String line = null; while ((line = reader.readLine()) != null) { lines.add(line); } reader.close(); return lines; } else { return null; } } SourceFileReader(String _type); }
SourceFileReader { public List<String> readFileIntoList(String filepath) throws IOException { if (type.contentEquals("local")) { List<String> lines = new ArrayList<>(); File file = new File(filepath); BufferedReader reader = new BufferedReader(new FileReader(file)); String line = null; while ((line = reader.readLine()) != null) { lines.add(line); } reader.close(); return lines; } else if (type.contentEquals("web")) { List<String> lines = new ArrayList<>(); URL url = new URL(filepath); BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream())); String line = null; while ((line = reader.readLine()) != null) { lines.add(line); } reader.close(); return lines; } else { return null; } } SourceFileReader(String _type); List<String> readFileIntoList(String filepath); String readFileIntoString(String filepath); }
SourceFileReader { public List<String> readFileIntoList(String filepath) throws IOException { if (type.contentEquals("local")) { List<String> lines = new ArrayList<>(); File file = new File(filepath); BufferedReader reader = new BufferedReader(new FileReader(file)); String line = null; while ((line = reader.readLine()) != null) { lines.add(line); } reader.close(); return lines; } else if (type.contentEquals("web")) { List<String> lines = new ArrayList<>(); URL url = new URL(filepath); BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream())); String line = null; while ((line = reader.readLine()) != null) { lines.add(line); } reader.close(); return lines; } else { return null; } } SourceFileReader(String _type); List<String> readFileIntoList(String filepath); String readFileIntoString(String filepath);  }