Code example for Path

Methods: getFileNameresolve

0
    assertReadText(autoOutFile("TXT")); 
    assertReadText(autoOutFile("TEXT")); 
  } 
   
  private Path rawTextFile(String ext) throws Exception {
    Path f = testDir.resolve("testfile." +  ext);
    BufferedWriter w = Files.newBufferedWriter(f, StandardCharsets.UTF_8);
    w.write(TEXT);
    w.newLine();
    w.close();
    return f;
  } 
   
  private Path rawGzipFile(String ext) throws Exception {
    Path f = testDir.resolve("testfile." +  ext);
    OutputStream os = new CompressorStreamFactory().createCompressorOutputStream(CompressorStreamFactory.GZIP, Files.newOutputStream(f));
    writeText(os);
    return f;
  } 
 
  private Path rawBzip2File(String ext) throws Exception {
    Path f = testDir.resolve("testfile." +  ext);
    OutputStream os = new CompressorStreamFactory().createCompressorOutputStream(CompressorStreamFactory.BZIP2, Files.newOutputStream(f));
    writeText(os);
    return f;
  } 
 
  private Path autoOutFile(String ext) throws Exception {
    Path f = testDir.resolve("testfile." +  ext);
    OutputStream os = StreamUtils.outputStream(f);
    writeText(os);
    return f;
  } 
 
  private void writeText(OutputStream os) throws IOException {
    BufferedWriter w = new BufferedWriter(new OutputStreamWriter(os, StandardCharsets.UTF_8));
    w.write(TEXT);
    w.newLine();
    w.close();
  } 
 
  private void assertReadText(Path f) throws Exception {
    InputStream ir = StreamUtils.inputStream(f);
    InputStreamReader in = new InputStreamReader(ir, StandardCharsets.UTF_8);
    BufferedReader r = new BufferedReader(in);
    String line = r.readLine();
    assertEquals("Wrong text found in "+f.getFileName(), TEXT, line);
    r.close();
  } 
   
  @Override 
  @Before