FilesystemUtils.java

  1. package org.jbehave.core.io.rest.filesystem;

  2. import static org.apache.commons.lang3.StringUtils.substringBeforeLast;

  3. import java.io.File;

  4. import org.apache.commons.lang3.StringUtils;
  5. import org.jbehave.core.io.rest.Resource;

  6. public class FilesystemUtils {

  7.     public static File asFile(Resource resource, String parentPath, String ext) {
  8.         String childPath = (resource.hasBreadcrumbs() ? StringUtils.join(resource.getBreadcrumbs(), "/") : "") + "/"
  9.                 + resource.getName() + ext;
  10.         return new File(parentPath, childPath);
  11.     }

  12.     public static String fileNameWithoutExt(File file) {
  13.         return substringBeforeLast(file.getName(), ".");
  14.     }

  15.     public static String normalisedPathOf(File file) {
  16.         return file.getPath().replace('\\','/');
  17.     }

  18. }