org.springframework.roo.support.util.FileUtils.getCanonicalPath()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(99)

本文整理了Java中org.springframework.roo.support.util.FileUtils.getCanonicalPath()方法的一些代码示例,展示了FileUtils.getCanonicalPath()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtils.getCanonicalPath()方法的具体详情如下:
包路径:org.springframework.roo.support.util.FileUtils
类名称:FileUtils
方法名:getCanonicalPath

FileUtils.getCanonicalPath介绍

[英]Returns the canonical path of the given File.
[中]返回给定文件的规范路径。

代码示例

代码示例来源:origin: spring-projects/spring-roo

/**
 * Each {@link FileDetails} is known by its canonical file name, which is
 * also the format used for Ant path matching etc. This method provides the
 * canonical file name without forcing the user to deal with the exceptions
 * that would arise from using {@link File} directly.
 * 
 * @return the canonical path.
 */
public String getCanonicalPath() {
 return FileUtils.getCanonicalPath(file);
}

代码示例来源:origin: spring-projects/spring-roo

public String getCanonicalPath() {
 return FileUtils.getCanonicalPath(file);
}

代码示例来源:origin: spring-projects/spring-roo

/**
 * Returns the canonical path of the given {@link File}.
 * 
 * @param file the file for which to find the canonical path (required)
 * @return the canonical path
 * @deprecated use {@link FileUtils#getCanonicalPath(File)} instead
 */
@Deprecated
public static String getCanonicalPath(final File file) {
 return FileUtils.getCanonicalPath(file);
}

代码示例来源:origin: spring-projects/spring-roo

/**
 * Constructor
 * 
 * @param logicalPath (required)
 * @param location the physical location of this path (required)
 */
public PhysicalPath(final LogicalPath logicalPath, final File location) {
 Validate.notNull(logicalPath, "Module path required");
 Validate.notNull(location, "Location required");
 canonicalPath = FileUtils.getCanonicalPath(location);
 this.logicalPath = logicalPath;
 this.location = location;
}

代码示例来源:origin: spring-projects/spring-roo

public String getMeaningfulName(final File file) {
  Validate.notNull(file, "File required");
  return pathResolver.getFriendlyName(FileUtils.getCanonicalPath(file));
 }
}

代码示例来源:origin: spring-projects/spring-roo

public String getRoot(final LogicalPath logicalPath) {
 Validate.notNull(logicalPath, "Path required");
 final PhysicalPath pathInfo = rootModulePaths.get(logicalPath.getPath());
 Validate.notNull(pathInfo, "Unable to determine information for path '" + logicalPath + "'");
 final File root = pathInfo.getLocation();
 return FileUtils.getCanonicalPath(root);
}

代码示例来源:origin: spring-projects/spring-roo

protected void activate(final ComponentContext cContext) {
 context = cContext.getBundleContext();
 final File projectDirectory =
   new File(StringUtils.defaultIfEmpty(OSGiUtils.getRooWorkingDirectory(cContext),
     FileUtils.CURRENT_DIRECTORY));
 projectRootDirectory = FileUtils.getCanonicalPath(projectDirectory);
}

代码示例来源:origin: spring-projects/spring-roo

protected void activate(final ComponentContext context) {
 final File projectDirectory =
   new File(StringUtils.defaultIfEmpty(OSGiUtils.getRooWorkingDirectory(context),
     CURRENT_DIRECTORY));
 rootPath = FileUtils.getCanonicalPath(projectDirectory);
}

代码示例来源:origin: spring-projects/spring-roo

public String getIdentifier(final LogicalPath logicalPath, final String relativePath) {
 Validate.notNull(logicalPath, "Path required");
 Validate.notNull(relativePath, "Relative path cannot be null, although it can be empty");
 String initialPath = FileUtils.getCanonicalPath(getPath(logicalPath));
 initialPath = FileUtils.ensureTrailingSeparator(initialPath);
 return initialPath + StringUtils.strip(relativePath, File.separator);
}

代码示例来源:origin: spring-projects/spring-roo

private String getProposedJavaType(final String fileCanonicalPath) {
 Validate.notBlank(fileCanonicalPath, "File canonical path required");
 // Determine the JavaType for this file
 String relativePath = "";
 final Pom moduleForFileIdentifier =
   getProjectOperations().getModuleForFileIdentifier(fileCanonicalPath);
 if (moduleForFileIdentifier == null) {
  return relativePath;
 }
 for (final PhysicalPath physicalPath : moduleForFileIdentifier.getPhysicalPaths()) {
  final String moduleCanonicalPath =
    FileUtils.ensureTrailingSeparator(FileUtils.getCanonicalPath(physicalPath.getLocation()));
  if (fileCanonicalPath.startsWith(moduleCanonicalPath)) {
   relativePath =
     File.separator + StringUtils.replace(fileCanonicalPath, moduleCanonicalPath, "", 1);
   break;
  }
 }
 Validate.notBlank(relativePath, "Could not determine compilation unit name for file '%s'",
   fileCanonicalPath);
 Validate.isTrue(relativePath.startsWith(File.separator),
   "Relative path unexpectedly dropped the '%s' prefix (received '%s' from '%s')",
   File.separator, relativePath, fileCanonicalPath);
 relativePath = relativePath.substring(1);
 Validate.isTrue(relativePath.endsWith(".java"),
   "The relative path unexpectedly dropped the .java extension for file '%s'",
   fileCanonicalPath);
 relativePath = relativePath.substring(0, relativePath.lastIndexOf(".java"));
 return relativePath.replace(File.separatorChar, '.');
}

代码示例来源:origin: spring-projects/spring-roo

public String backup() {
 Validate.isTrue(isBackupPossible(), "Project metadata unavailable");
 // For Windows, make a date format that can legally form part of a
 // filename (ROO-277)
 final String pattern =
   File.separatorChar == '\\' ? "yyyy-MM-dd_HH.mm.ss" : "yyyy-MM-dd_HH:mm:ss";
 final DateFormat df = new SimpleDateFormat(pattern);
 final long start = System.nanoTime();
 ZipOutputStream zos = null;
 try {
  final File projectDirectory =
    new File(getProjectOperations().getPathResolver().getFocusedIdentifier(Path.ROOT, "."));
  final MutableFile file =
    getFileManager().createFile(
      FileUtils.getCanonicalPath(new File(projectDirectory, getProjectOperations()
        .getFocusedProjectName() + "_" + df.format(new Date()) + ".zip")));
  zos = new ZipOutputStream(file.getOutputStream());
  zip(projectDirectory, projectDirectory, zos);
 } catch (final FileNotFoundException e) {
  LOGGER.fine("Could not determine project directory");
 } catch (final IOException e) {
  LOGGER.fine("Could not create backup archive");
 } finally {
  IOUtils.closeQuietly(zos);
 }
 final long milliseconds = (System.nanoTime() - start) / 1000000;
 return "Backup completed in " + milliseconds + " ms";
}

代码示例来源:origin: org.springframework.roo/org.springframework.roo.file.monitor

/**
 * Each {@link FileDetails} is known by its canonical file name, which is
 * also the format used for Ant path matching etc. This method provides the
 * canonical file name without forcing the user to deal with the exceptions
 * that would arise from using {@link File} directly.
 * 
 * @return the canonical path.
 */
public String getCanonicalPath() {
 return FileUtils.getCanonicalPath(file);
}

代码示例来源:origin: org.springframework.roo/org.springframework.roo.process.manager

public String getCanonicalPath() {
 return FileUtils.getCanonicalPath(file);
}

代码示例来源:origin: org.springframework.roo/org.springframework.roo.file.monitor

/**
 * Returns the canonical path of the given {@link File}.
 * 
 * @param file the file for which to find the canonical path (required)
 * @return the canonical path
 * @deprecated use {@link FileUtils#getCanonicalPath(File)} instead
 */
@Deprecated
public static String getCanonicalPath(final File file) {
 return FileUtils.getCanonicalPath(file);
}

代码示例来源:origin: org.springframework.roo/org.springframework.roo.classpath

private String getProposedJavaType(final String fileCanonicalPath) {
 Validate.notBlank(fileCanonicalPath, "File canonical path required");
 // Determine the JavaType for this file
 String relativePath = "";
 final Pom moduleForFileIdentifier =
   getProjectOperations().getModuleForFileIdentifier(fileCanonicalPath);
 if (moduleForFileIdentifier == null) {
  return relativePath;
 }
 for (final PhysicalPath physicalPath : moduleForFileIdentifier.getPhysicalPaths()) {
  final String moduleCanonicalPath =
    FileUtils.ensureTrailingSeparator(FileUtils.getCanonicalPath(physicalPath.getLocation()));
  if (fileCanonicalPath.startsWith(moduleCanonicalPath)) {
   relativePath =
     File.separator + StringUtils.replace(fileCanonicalPath, moduleCanonicalPath, "", 1);
   break;
  }
 }
 Validate.notBlank(relativePath, "Could not determine compilation unit name for file '%s'",
   fileCanonicalPath);
 Validate.isTrue(relativePath.startsWith(File.separator),
   "Relative path unexpectedly dropped the '%s' prefix (received '%s' from '%s')",
   File.separator, relativePath, fileCanonicalPath);
 relativePath = relativePath.substring(1);
 Validate.isTrue(relativePath.endsWith(".java"),
   "The relative path unexpectedly dropped the .java extension for file '%s'",
   fileCanonicalPath);
 relativePath = relativePath.substring(0, relativePath.lastIndexOf(".java"));
 return relativePath.replace(File.separatorChar, '.');
}

相关文章