org.apache.camel.util.FileUtil.stripLeadingSeparator()方法的使用及代码示例

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

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

FileUtil.stripLeadingSeparator介绍

暂无

代码示例

代码示例来源:origin: org.apache.camel/camel-ftp

/**
 * Checks whether directory used in ftp/ftps/sftp endpoint URI is relative.
 * Absolute path will be converted to relative path and a WARN will be printed.
 * @see <a href="http://camel.apache.org/ftp2.html">FTP/SFTP/FTPS Component</a>
 * @param ftpComponent
 * @param configuration
 */
public static void ensureRelativeFtpDirectory(Component ftpComponent, RemoteFileConfiguration configuration) {
  if (FileUtil.hasLeadingSeparator(configuration.getDirectoryName())) {
    String relativePath = FileUtil.stripLeadingSeparator(configuration.getDirectoryName());
    LOG.warn(String.format("%s doesn't support absolute paths, \"%s\" will be converted to \"%s\". "
        + "After Camel 2.16, absolute paths will be invalid.",
        ftpComponent.getClass().getSimpleName(),
        configuration.getDirectoryName(),
        relativePath));
    configuration.setDirectory(relativePath);
    configuration.setDirectoryName(relativePath);
  }
}

代码示例来源:origin: org.apache.camel/camel-http

basePath = FileUtil.stripLeadingSeparator(basePath);
uriTemplate = FileUtil.stripLeadingSeparator(uriTemplate);

代码示例来源:origin: org.apache.camel/camel-ftp

to = FileUtil.stripLeadingSeparator(to);

代码示例来源:origin: org.apache.camel/camel-undertow

basePath = FileUtil.stripLeadingSeparator(basePath);
uriTemplate = FileUtil.stripLeadingSeparator(uriTemplate);

代码示例来源:origin: org.apache.camel/camel-netty-http

path = FileUtil.stripLeadingSeparator(path);
if (ObjectHelper.isNotEmpty(contextPath)) {
  contextPath = FileUtil.stripTrailingSeparator(contextPath);
  contextPath = FileUtil.stripLeadingSeparator(contextPath);
  if (ObjectHelper.isNotEmpty(contextPath)) {
    path = contextPath + "/" + path;

代码示例来源:origin: org.apache.camel/camel-servlet

path = FileUtil.stripLeadingSeparator(path);

代码示例来源:origin: org.apache.camel/camel-coap

path = FileUtil.stripLeadingSeparator(path);
if (ObjectHelper.isNotEmpty(contextPath)) {
  contextPath = FileUtil.stripTrailingSeparator(contextPath);
  contextPath = FileUtil.stripLeadingSeparator(contextPath);
  if (ObjectHelper.isNotEmpty(contextPath)) {
    path = contextPath + "/" + path;

代码示例来源:origin: org.apache.camel/camel-undertow

path = FileUtil.stripLeadingSeparator(path);
String scheme = "http";
String host = "";
if (ObjectHelper.isNotEmpty(contextPath)) {
  contextPath = FileUtil.stripTrailingSeparator(contextPath);
  contextPath = FileUtil.stripLeadingSeparator(contextPath);
  if (ObjectHelper.isNotEmpty(contextPath)) {
    path = contextPath + "/" + path;

代码示例来源:origin: org.apache.camel/camel-ftp

to = FileUtil.stripLeadingSeparator(to);

代码示例来源:origin: org.apache.camel/camel-ftp

private RemoteFile<SftpRemoteFile> asRemoteFile(String absolutePath, SftpRemoteFile file, String charset) {
  RemoteFile<SftpRemoteFile> answer = new RemoteFile<>();
  answer.setCharset(charset);
  answer.setEndpointPath(endpointPath);
  answer.setFile(file);
  answer.setFileNameOnly(file.getFilename());
  answer.setFileLength(file.getFileLength());
  answer.setLastModified(file.getLastModified());
  answer.setHostname(((RemoteFileConfiguration) endpoint.getConfiguration()).getHost());
  answer.setDirectory(file.isDirectory());
  // absolute or relative path
  boolean absolute = FileUtil.hasLeadingSeparator(absolutePath);
  answer.setAbsolute(absolute);
  // create a pseudo absolute name
  String dir = FileUtil.stripTrailingSeparator(absolutePath);
  String absoluteFileName = FileUtil.stripLeadingSeparator(dir + "/" + file.getFilename());
  // if absolute start with a leading separator otherwise let it be relative
  if (absolute) {
    absoluteFileName = "/" + absoluteFileName;
  }
  answer.setAbsoluteFilePath(absoluteFileName);
  // the relative filename, skip the leading endpoint configured path
  String relativePath = ObjectHelper.after(absoluteFileName, endpointPath);
  // skip trailing /
  relativePath = FileUtil.stripLeadingSeparator(relativePath);
  answer.setRelativeFilePath(relativePath);
  // the file name should be the relative path
  answer.setFileName(answer.getRelativeFilePath());
  return answer;
}

代码示例来源:origin: org.apache.camel/camel-ftp

fileName = FtpUtils.extractDirNameFromAbsolutePath(file.getName());
String absoluteFileName = FileUtil.stripLeadingSeparator(dir + "/" + fileName);
relativePath = FileUtil.stripLeadingSeparator(relativePath);
answer.setRelativeFilePath(relativePath);

相关文章