@Test public void testReadFileIntoStringLocal() throws IOException { sfr = new SourceFileReader(TYPE_LOCAL); String actuals = sfr.readFileIntoString(TEST_CLASS_LOCAL); assertEquals(expectedString, actuals); }
public String readFileIntoString(String filepath) throws IOException { if (type.contentEquals("local")) { StringBuilder sb = new StringBuilder(); File file = new File(filepath); BufferedReader reader = new BufferedReader(new FileReader(file)); String line = null; while ((line = reader.readLine()) != null) { sb.append(line + "\n"); } reader.close(); return sb.toString(); } else if (type.contentEquals("web")) { StringBuilder sb = new StringBuilder(); URL url = new URL(filepath); BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream())); String line = null; while ((line = reader.readLine()) != null) { sb.append(line + "\n"); } reader.close(); return sb.toString(); } else { return null; } }
SourceFileReader { public String readFileIntoString(String filepath) throws IOException { if (type.contentEquals("local")) { StringBuilder sb = new StringBuilder(); File file = new File(filepath); BufferedReader reader = new BufferedReader(new FileReader(file)); String line = null; while ((line = reader.readLine()) != null) { sb.append(line + "\n"); } reader.close(); return sb.toString(); } else if (type.contentEquals("web")) { StringBuilder sb = new StringBuilder(); URL url = new URL(filepath); BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream())); String line = null; while ((line = reader.readLine()) != null) { sb.append(line + "\n"); } reader.close(); return sb.toString(); } else { return null; } } }
SourceFileReader { public String readFileIntoString(String filepath) throws IOException { if (type.contentEquals("local")) { StringBuilder sb = new StringBuilder(); File file = new File(filepath); BufferedReader reader = new BufferedReader(new FileReader(file)); String line = null; while ((line = reader.readLine()) != null) { sb.append(line + "\n"); } reader.close(); return sb.toString(); } else if (type.contentEquals("web")) { StringBuilder sb = new StringBuilder(); URL url = new URL(filepath); BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream())); String line = null; while ((line = reader.readLine()) != null) { sb.append(line + "\n"); } reader.close(); return sb.toString(); } else { return null; } } SourceFileReader(String _type); }
SourceFileReader { public String readFileIntoString(String filepath) throws IOException { if (type.contentEquals("local")) { StringBuilder sb = new StringBuilder(); File file = new File(filepath); BufferedReader reader = new BufferedReader(new FileReader(file)); String line = null; while ((line = reader.readLine()) != null) { sb.append(line + "\n"); } reader.close(); return sb.toString(); } else if (type.contentEquals("web")) { StringBuilder sb = new StringBuilder(); URL url = new URL(filepath); BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream())); String line = null; while ((line = reader.readLine()) != null) { sb.append(line + "\n"); } reader.close(); return sb.toString(); } else { return null; } } SourceFileReader(String _type); List<String> readFileIntoList(String filepath); String readFileIntoString(String filepath); }
SourceFileReader { public String readFileIntoString(String filepath) throws IOException { if (type.contentEquals("local")) { StringBuilder sb = new StringBuilder(); File file = new File(filepath); BufferedReader reader = new BufferedReader(new FileReader(file)); String line = null; while ((line = reader.readLine()) != null) { sb.append(line + "\n"); } reader.close(); return sb.toString(); } else if (type.contentEquals("web")) { StringBuilder sb = new StringBuilder(); URL url = new URL(filepath); BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream())); String line = null; while ((line = reader.readLine()) != null) { sb.append(line + "\n"); } reader.close(); return sb.toString(); } else { return null; } } SourceFileReader(String _type); List<String> readFileIntoList(String filepath); String readFileIntoString(String filepath);  }