@Test public void testReadFile() throws Exception{ PlainFileReader plainFileReader = new PlainFileReader(reader); expect(reader.readLine()).andReturn("na"); expect(reader.readLine()).andReturn("und"); expect(reader.readLine()).andReturn("nu"); expect(reader.readLine()).andReturn(null); replay(reader); String[] lines = plainFileReader.readLines(); verify(reader); assertEquals(3, lines.length); assertEquals("na", lines[0]); assertEquals("und", lines[1]); assertEquals("nu", lines[2]); }
public String[] readLines() throws IOException { List<String> lines = new ArrayList<String>(); String line = reader.readLine(); while (line != null) { lines.add(line.trim()); line = reader.readLine(); } String[] stopwords = new String[lines.size()]; lines.toArray(stopwords); return stopwords; }
PlainFileReader extends Reader { public String[] readLines() throws IOException { List<String> lines = new ArrayList<String>(); String line = reader.readLine(); while (line != null) { lines.add(line.trim()); line = reader.readLine(); } String[] stopwords = new String[lines.size()]; lines.toArray(stopwords); return stopwords; } }
PlainFileReader extends Reader { public String[] readLines() throws IOException { List<String> lines = new ArrayList<String>(); String line = reader.readLine(); while (line != null) { lines.add(line.trim()); line = reader.readLine(); } String[] stopwords = new String[lines.size()]; lines.toArray(stopwords); return stopwords; } PlainFileReader(BufferedReader reader); }
PlainFileReader extends Reader { public String[] readLines() throws IOException { List<String> lines = new ArrayList<String>(); String line = reader.readLine(); while (line != null) { lines.add(line.trim()); line = reader.readLine(); } String[] stopwords = new String[lines.size()]; lines.toArray(stopwords); return stopwords; } PlainFileReader(BufferedReader reader); String[] readLines(); @Override void close(); @Override int read(char[] cbuf, int off, int len); }
PlainFileReader extends Reader { public String[] readLines() throws IOException { List<String> lines = new ArrayList<String>(); String line = reader.readLine(); while (line != null) { lines.add(line.trim()); line = reader.readLine(); } String[] stopwords = new String[lines.size()]; lines.toArray(stopwords); return stopwords; } PlainFileReader(BufferedReader reader); String[] readLines(); @Override void close(); @Override int read(char[] cbuf, int off, int len);  }