本文整理了Java中org.springframework.roo.support.util.FileUtils.getFirstDirectory()
方法的一些代码示例,展示了FileUtils.getFirstDirectory()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtils.getFirstDirectory()
方法的具体详情如下:
包路径:org.springframework.roo.support.util.FileUtils
类名称:FileUtils
方法名:getFirstDirectory
[英]Returns the part of the given path that represents a directory, in other words the given path if it's already a directory, or the parent directory if it's a file.
[中]返回给定路径中表示目录的部分,换句话说,如果给定路径已经是目录,则返回该路径;如果它是文件,则返回父目录。
代码示例来源:origin: spring-projects/spring-roo
public Pom getModuleForFileIdentifier(final String fileIdentifier) {
updatePomCache();
String startingPoint = FileUtils.getFirstDirectory(fileIdentifier);
String pomPath = FileUtils.ensureTrailingSeparator(startingPoint) + DEFAULT_POM_NAME;
File pom = new File(pomPath);
while (!pom.exists()) {
if (startingPoint.equals(SEPARATOR)) {
break;
}
startingPoint = StringUtils.removeEnd(startingPoint, SEPARATOR);
if (startingPoint.lastIndexOf(SEPARATOR) < 0) {
break;
}
startingPoint = startingPoint.substring(0, startingPoint.lastIndexOf(SEPARATOR));
startingPoint = StringUtils.removeEnd(startingPoint, SEPARATOR);
pomPath = FileUtils.ensureTrailingSeparator(startingPoint) + DEFAULT_POM_NAME;
pom = new File(pomPath);
}
return getPomFromPath(pomPath);
}
代码示例来源:origin: spring-projects/spring-roo
private Set<Pom> parseUnparsedPoms() {
final Map<String, String> pomModuleMap = new HashMap<String, String>();
final Set<Pom> newPoms = new HashSet<Pom>();
for (final Iterator<String> iter = toBeParsed.iterator(); iter.hasNext();) {
final String pathToChangedPom = iter.next();
if (new File(pathToChangedPom).exists()) {
String pomContents = "";
try {
pomContents =
org.apache.commons.io.FileUtils.readFileToString(new File(pathToChangedPom));
} catch (IOException ignored) {
}
if (StringUtils.isNotBlank(pomContents)) {
final Element rootElement = XmlUtils.stringToElement(pomContents);
resolvePoms(rootElement, pathToChangedPom, pomModuleMap);
final String moduleName = getModuleName(FileUtils.getFirstDirectory(pathToChangedPom));
final Pom pom = getPomFactory().getInstance(rootElement, pathToChangedPom, moduleName);
Validate.notNull(pom, "POM is null for module '%s' and path '%s'", moduleName,
pathToChangedPom);
pomMap.put(pathToChangedPom, pom);
newPoms.add(pom);
iter.remove();
}
}
}
return newPoms;
}
代码示例来源:origin: spring-projects/spring-roo
/**
* Returns the {@link PhysicalPath} of this {@link Path} within the module
* to which the given POM belongs.
*
* @param pom the POM of the module in question (required)
* @return a non-<code>null</code> instance
*/
public PhysicalPath getModulePath(final Pom pom) {
return getModulePath(pom.getModuleName(), FileUtils.getFirstDirectory(pom.getPath()), pom);
}
代码示例来源:origin: spring-projects/spring-roo
return physicalTypeIdentifier;
final String typeDirectory = FileUtils.getFirstDirectory(fileCanonicalPath);
final String simpleTypeName =
StringUtils.replace(fileCanonicalPath, typeDirectory + File.separator, "", 1).replace(
代码示例来源:origin: org.springframework.roo/org.springframework.roo.classpath
return physicalTypeIdentifier;
final String typeDirectory = FileUtils.getFirstDirectory(fileCanonicalPath);
final String simpleTypeName =
StringUtils.replace(fileCanonicalPath, typeDirectory + File.separator, "", 1).replace(
内容来源于网络,如有侵权,请联系作者删除!