Package jodd.io.findfile

Examples of jodd.io.findfile.FindFile$FilesIterator


  /**
   * Applies the template to form the final message.
   */
  public void applyTemplate(Email email, EmailMessage emailMessage) {

    FindFile ff = new FindFile();
    ff.setIncludeDirs(false);
    ff.searchPath(templatePath + File.separatorChar + emailMessage.getTemplate());

    File f;
    while ((f = ff.nextFile()) != null) {
      if (f.getName().equals(MESSAGE_HTML)) {
        String template = null;
        try {
          template = FileUtil.readString(f);
        } catch (IOException ioex) {
View Full Code Here


     * Formats java files under provided source folder.
     */
    public void formatJava(String sourceRoot) throws IOException {
        System.out.println("*** format: " + sourceRoot);

        FindFile ff = new WildcardFindFile()
                .include("/webit-script/src/**/*.java")
                //.exclude("**/asm4/**/*.java","**/Lexer.java","**/Parser.java","**/Tokens.java")
                .setRecursive(true)
                .setIncludeDirs(false)
                .setMatchType(FindFile.Match.RELATIVE_PATH)
                .searchPath(sourceRoot);

        File f;
        int count = 0;
        while ((f = ff.nextFile()) != null) {
            boolean changed = format(f);

            if (changed) {
                count++;
            }
View Full Code Here

    dataRoot = data.getFile();
  }

  @Test
  public void testTwoAccept() {
    FindFile ff = new WildcardFindFile()
            .include("**/*file/a.png")
            .include("**/*file/a.txt")
            .setRecursive(true)
            .setIncludeDirs(true)
            .searchPath(dataRoot);

    int countFiles = 0;
    int countDirs = 0;

    File f;
    while ((f = ff.nextFile()) != null) {
      if (f.isDirectory() == true) {
        countDirs++;
      } else {
        countFiles++;
        String path = f.getAbsolutePath();
View Full Code Here

    assertEquals(2, countFiles);
  }

  @Test
  public void testWildcardFile() {
    FindFile ff = new WildcardFindFile()
        .include("**/*file/a*")
        .setRecursive(true)
        .setIncludeDirs(true)
        .searchPath(dataRoot);

    int countDirs = 0;
    int countFiles = 0;

    File f;
    while ((f = ff.nextFile()) != null) {
      if (f.isDirectory() == true) {
        countDirs++;
      } else {
        countFiles++;
        String path = f.getAbsolutePath();
        path = FileNameUtil.separatorsToUnix(path);
        if (path.startsWith("/") == false) {
          path = '/' + path;
        }
        boolean matched =
            path.equals(dataRoot + "/file/a.png") ||
                path.equals(dataRoot + "/file/a.txt");

        assertTrue(matched);

      }
    }

    assertEquals(0, countDirs);
    assertEquals(2, countFiles);

    ff.searchPath(dataRoot);

    countDirs = 0;
    countFiles = 0;

    Iterator<File> iterator = ff.iterator();

    while (iterator.hasNext()) {
      f = iterator.next();

      if (f.isDirectory() == true) {
View Full Code Here

  }


  @Test
  public void testWildcardPath() {
    FindFile ff = new WildcardFindFile()
        .include("**/file/*")
        .setRecursive(true)
        .setIncludeDirs(true)
        .searchPath(dataRoot);

    int countDirs = 0;
    int countFiles = 0;

    File f;
    while ((f = ff.nextFile()) != null) {
      if (f.isDirectory() == true) {
        countDirs++;
      } else {
        countFiles++;
        String path = f.getAbsolutePath();
View Full Code Here

    assertEquals(2, countFiles);
  }

  @Test
  public void testRegexp() {
    FindFile ff = new RegExpFindFile()
        .include(".*/a[.].*")
        .setRecursive(true)
        .setIncludeDirs(true)
        .searchPath(dataRoot);

    int countDirs = 0;
    int countFiles = 0;

    File f;
    while ((f = ff.nextFile()) != null) {
      if (f.isDirectory() == true) {
        countDirs++;
      } else {
        countFiles++;
        String path = f.getAbsolutePath();
View Full Code Here

    if (strategy == Strategy.ACTION_MANAGED) {
      actionBundles.clear();
      mirrors.clear();
    }

    FindFile ff = new FindFile();
    ff.setIncludeDirs(false);
    ff.searchPath(new File(bundleFolder, staplerPath));

    File f;
    int count = 0;
    while ((f = ff.nextFile()) != null) {
      f.delete();
      count++;
    }
    if (log.isInfoEnabled()) {
      log.info("reset: " + count + " bundle files deleted.");
View Full Code Here

  public void testHtmls2() throws IOException {
    _testHtmls(testDataRoot2);
  }

  private void _testHtmls(String root) throws IOException {
    FindFile ff = new WildcardFindFile().include("**/*.*ml");
    long reps = 1;
    JStopWatch jsw = new JStopWatch();
    boolean processed = false;
    while (reps-- > 0) {
      ff.searchPath(root);
      File file;
      while ((file = ff.nextFile()) != null) {
        processed = true;
        System.out.println('+' + file.getName());

        String content = FileUtil.readString(file);
        content = StringUtil.removeChars(content, '\r');
View Full Code Here

  /**
   * 13s
   */
  @Test
  public void testLiveHtmls() throws IOException {
    FindFile ff = new WildcardFindFile().include("**/*.html");
    ff.searchPath(testLiveRoot);
    File file;
    boolean processed = false;
    while ((file = ff.nextFile()) != null) {
      processed = true;
      String name = file.getName();
      System.out.println('+' + name);
      String content = FileUtil.readString(file);
      try {
View Full Code Here

  @Test
  public void testDecoraParser() throws IOException {
    DecoraParser decoraParser = new DecoraParser();

    FindFile ff = new WildcardFindFile().include("*.*ml");
    ff.setMatchType(FindFile.Match.NAME);
    ff.searchPath(testDataRoot);

    File file;
    while ((file = ff.nextFile()) != null) {

      System.out.println("+" + file.getName());

      char[] page = FileUtil.readString(file).toCharArray();

View Full Code Here

TOP

Related Classes of jodd.io.findfile.FindFile$FilesIterator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.