@Test public void testNoPathDropsExtension() { assertThat(LKFileUtils.basename("readme.txt", false), equalTo("readme")); }
@Test public void testNoPathPreservesExtension() { assertThat(LKFileUtils.basename("readme.txt", true), equalTo("readme.txt")); }
@Test public void testKeepDotfileName() { // dotfiles should not have extensions stripped, because they do have names assertThat(LKFileUtils.basename(".dotfile", false), equalTo(".dotfile")); } }
/** * Create a static data source from a CSV rating file. * @param file The CSV rating file. * @return The data source. */ public static StaticDataSource csvRatingFile(Path file) { StaticDataSource src = new StaticDataSource(); TextEntitySource text = new TextEntitySource(LKFileUtils.basename(file.toString(), false)); text.setFormat(Formats.csvRatings()); text.setFile(file); src.addSource(text); return src; }
/** * Create a static data source from a CSV rating file. * @param file The CSV rating file. * @return The data source. */ public static StaticDataSource csvRatingFile(Path file) { StaticDataSource src = new StaticDataSource(); TextEntitySource text = new TextEntitySource(LKFileUtils.basename(file.toString(), false)); text.setFormat(Formats.csvRatings()); text.setFile(file); src.addSource(text); return src; }