Filesystem { public Single<String> readTextFileFullyFromClasspath(String resourcePath) { URL resourceUri = getClass().getResource(resourcePath); if (resourceUri == null) { return Single.error(new NoSuchFileException(resourcePath)); } else { return readTextFileFully(getClass().getResource(resourcePath).getFile()); } }  Flowable<String> readTextFile(String pathToFile); Flowable<String> readTextFileFromClasspath(String resourcePath); Single<String> readTextFileFully(String pathToFile); Single<String> readTextFileFullyFromClasspath(String resourcePath); Completable writeFile(final String content, String filePath); Completable writeFileSync(String content, String filePath, boolean append); Completable writeFileSync(String content, Charset encoding, String filePath, boolean append);  }
@Test void testReadTextFileFullyFromClasspath() { assertThat(filesystem.readTextFileFullyFromClasspath("/someFile.txt").blockingGet(), is("This is some content in some file." + System.lineSeparator() + System.lineSeparator() + "This is more content.")); }
@Test void testReadFileFromClasspathSyncWithUnknownPathThrowsException() { try { filesystem.readTextFileFullyFromClasspath("src/test/resources/" + System.currentTimeMillis() + ".txt") .blockingGet(); Assertions.fail("Exception expected"); } catch (Exception e) { assertTrue(e.getCause() instanceof NoSuchFileException); } }