@Test public void testValidFile() throws IOException { final File temp = File.createTempFile("testFactory", "java"); try { final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(temp), "UTF-8")); try { writer.write("hello"); } finally { writer.close(); } final SourceFactory factory = new FileSourceFactory(); final List<? extends Source> sources = factory.createSources(temp.getAbsolutePath()); assertEquals(1, sources.size()); final Source source = sources.get(0); final BufferedReader reader = source.createReader(); try { assertEquals("hello", reader.readLine()); assertEquals(temp.getAbsolutePath(), source.getSrcInfo()); } finally { reader.close(); } } finally { temp.delete(); } }
@Override public List<FileSource> createSources(String srcName) { final File dirOrFile = new File(srcName); final File[] files = dirOrFile.listFiles(FILTER); if (files != null) { final List<FileSource> sources = new ArrayList<FileSource>(files.length); for (File file : files) { sources.add(new FileSource(file)); } return sources; } else { return Util.list(new FileSource(dirOrFile)); } }
FileSourceFactory implements SourceFactory { @Override public List<FileSource> createSources(String srcName) { final File dirOrFile = new File(srcName); final File[] files = dirOrFile.listFiles(FILTER); if (files != null) { final List<FileSource> sources = new ArrayList<FileSource>(files.length); for (File file : files) { sources.add(new FileSource(file)); } return sources; } else { return Util.list(new FileSource(dirOrFile)); } } }
FileSourceFactory implements SourceFactory { @Override public List<FileSource> createSources(String srcName) { final File dirOrFile = new File(srcName); final File[] files = dirOrFile.listFiles(FILTER); if (files != null) { final List<FileSource> sources = new ArrayList<FileSource>(files.length); for (File file : files) { sources.add(new FileSource(file)); } return sources; } else { return Util.list(new FileSource(dirOrFile)); } }  }
FileSourceFactory implements SourceFactory { @Override public List<FileSource> createSources(String srcName) { final File dirOrFile = new File(srcName); final File[] files = dirOrFile.listFiles(FILTER); if (files != null) { final List<FileSource> sources = new ArrayList<FileSource>(files.length); for (File file : files) { sources.add(new FileSource(file)); } return sources; } else { return Util.list(new FileSource(dirOrFile)); } }  @Override List<FileSource> createSources(String srcName); }
FileSourceFactory implements SourceFactory { @Override public List<FileSource> createSources(String srcName) { final File dirOrFile = new File(srcName); final File[] files = dirOrFile.listFiles(FILTER); if (files != null) { final List<FileSource> sources = new ArrayList<FileSource>(files.length); for (File file : files) { sources.add(new FileSource(file)); } return sources; } else { return Util.list(new FileSource(dirOrFile)); } }  @Override List<FileSource> createSources(String srcName);  }