Exemple #1
0
  @Test
  public void testMakeRelative() {
    String tmpDir = System.getProperty("java.io.tmpdir");
    File base = new File(tmpDir);
    File file = new File(tmpDir, "delme" + System.currentTimeMillis());
    file.mkdir();
    File f1 = new File(file, "anotherdelme");

    String val = IOUtil.makeRelative(f1, base);

    System.out.println(val);
  }
Exemple #2
0
  @Test
  public void testListFiles() throws Exception {
    File tmpDir = File.createTempFile("testIOUtil", "tmp");
    System.out.println("temp location is: " + tmpDir.getAbsolutePath());
    tmpDir.mkdirs();
    File f1 = new File(tmpDir, "1.dd");
    File f2 = new File(tmpDir, "2.dd");
    try {
      f1.createNewFile();
      f2.createNewFile();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    StringWriter swriter = new StringWriter();
    swriter.append(f1.getAbsolutePath() + System.getProperty("line.separator"));
    swriter.append(f2.getAbsolutePath() + System.getProperty("line.separator"));
    File outFile = new File(tmpDir, "delme");
    String extension = "dd";
    IOUtil.listFiles(tmpDir, outFile, extension);
    // assertThat(outFile,fileLineCountEquals(2));

  }