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

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

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

FileUtil.stripPath介绍

暂无

代码示例

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

public static String extractDirNameFromAbsolutePath(String path) {
  // default is unix so try with '/'
  // otherwise force File.separator
  if (path.endsWith("/") || path.endsWith("\\")) {
    path = path.substring(0, path.length() - 1);
  }
  return FileUtil.stripPath(path);
}

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

@Override
protected boolean isMatched(GenericFile<FTPFile> file, String doneFileName, List<FTPFile> files) {
  String onlyName = FileUtil.stripPath(doneFileName);
  for (FTPFile f : files) {
    if (f.getName().equals(onlyName)) {
      return true;
    }
  }
  log.trace("Done file: {} does not exist", doneFileName);
  return false;
}

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

@Override
protected boolean isMatched(GenericFile<SftpRemoteFile> file, String doneFileName, List<SftpRemoteFile> files) {
  String onlyName = FileUtil.stripPath(doneFileName);
  for (SftpRemoteFile f : files) {
    if (f.getFilename().equals(onlyName)) {
      return true;
    }
  }
  log.trace("Done file: {} does not exist", doneFileName);
  return false;
}

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

private Map<String, List<CamelNodeDetails>> groupAnonymousRoutesByClassName(List<CamelNodeDetails> anonymousRouteTrees) {
  Map<String, List<CamelNodeDetails>> answer = new LinkedHashMap<>();
  for (CamelNodeDetails t : anonymousRouteTrees) {
    String fileName = asRelativeFile(t.getFileName());
    String className = FileUtil.stripExt(FileUtil.stripPath(fileName));
    List<CamelNodeDetails> list = answer.computeIfAbsent(className, k -> new ArrayList<>());
    list.add(t);
  }
  return answer;
}

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

@Override
public Enumeration<URL> loadAllResourcesAsURL(String uri) {
  ObjectHelper.notEmpty(uri, "uri");
  Vector<URL> answer = new Vector<>();
  try {
    String resolvedName = resolveUriPath(uri);
    Enumeration<URL> e = bundleContext.getBundle().getResources(resolvedName);
    while (e != null && e.hasMoreElements()) {
      answer.add(e.nextElement());
    }
    String path = FileUtil.onlyPath(uri);
    String name = FileUtil.stripPath(uri);
    if (path != null && name != null) {
      for (Bundle bundle : bundleContext.getBundles()) {
        LOG.trace("Finding all entries in path: {} with pattern: {}", path, name);
        e = bundle.findEntries(path, name, false);
        while (e != null && e.hasMoreElements()) {
          answer.add(e.nextElement());
        }
      }
    }
  } catch (IOException e) {
    throw new RuntimeException("Cannot load resource: " + uri, e);
  }
  return answer.elements();
}

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

String onlyName = FileUtil.stripPath(name);
    String existing = entry.getFilename();
    LOG.trace("Existing file: {}, target file: {}", existing, name);
    existing = FileUtil.stripPath(existing);
    if (existing != null && existing.equals(onlyName)) {
      return true;

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

String onlyName = FileUtil.stripPath(name);
try {
  String[] names;
    existing = FileUtil.stripPath(existing);
    if (existing != null && existing.equals(onlyName)) {
      return true;

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

} else {
  String disposition = part.getDisposition();
  String fileName = FileUtil.stripPath(part.getFileName());

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

@Override
protected void doStart() throws Exception {
  super.doStart();
  // use file watch service if we read from file
  if (endpoint.isFileWatcher()) {
    String dir = new File(endpoint.getFileName()).getParent();
    fileWatcher = new FileWatcherStrategy(dir, (file) -> {
      String onlyName = file.getName();
      String target = FileUtil.stripPath(endpoint.getFileName());
      LOG.trace("File changed: {}", onlyName);
      if (onlyName.equals(target)) {
        // file is changed
        watchFileChanged = true;
      }
    });
    fileWatcher.setCamelContext(getEndpoint().getCamelContext());
  }
  ServiceHelper.startService(fileWatcher);
  // if we scan the stream we are lenient and can wait for the stream to be available later
  if (!endpoint.isScanStream()) {
    initializeStream();
  }
  executor = endpoint.getCamelContext().getExecutorServiceManager().newSingleThreadExecutor(this, endpoint.getEndpointUri());
  executor.execute(this);
  if (endpoint.getGroupLines() < 0) {
    throw new IllegalArgumentException("Option groupLines must be 0 or positive number, was " + endpoint.getGroupLines());
  }
}

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

String onlyName = FileUtil.stripPath(fileName);
dummy.getIn().setHeader(Exchange.FILE_NAME, fileName);
dummy.getIn().setHeader(Exchange.FILE_NAME_ONLY, onlyName);

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

remoteName = FileUtil.stripPath(name);

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

public boolean deleteFile(String name) throws GenericFileOperationFailedException {
  log.debug("Deleting file: {}", name);
  boolean result;
  String target = name;
  String currentDir = null;
  try {
    if (endpoint.getConfiguration().isStepwise()) {
      // remember current directory
      currentDir = getCurrentDirectory();
      target = FileUtil.stripPath(name);
      try {
        changeCurrentDirectory(FileUtil.onlyPath(name));
      } catch (GenericFileOperationFailedException e) {
        // we could not change directory, try to change back before
        changeCurrentDirectory(currentDir);
        throw e;
      }
    }
    // delete the file
    log.trace("Client deleteFile: {}", target);
    result = client.deleteFile(target);
    // change back to previous directory
    if (currentDir != null) {
      changeCurrentDirectory(currentDir);
    }
  } catch (IOException e) {
    throw new GenericFileOperationFailedException(client.getReplyCode(), client.getReplyString(), e.getMessage(), e);
  }
  return result;
}

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

remoteName = FileUtil.stripPath(name);

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

remoteName = FileUtil.stripPath(name);

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

public synchronized boolean storeFile(String name, Exchange exchange, long size) throws GenericFileOperationFailedException {
  // must normalize name first
  name = endpoint.getConfiguration().normalizePath(name);
  LOG.trace("storeFile({})", name);
  boolean answer = false;
  String currentDir = null;
  String path = FileUtil.onlyPath(name);
  String targetName = name;
  try {
    if (path != null && endpoint.getConfiguration().isStepwise()) {
      // must remember current dir so we stay in that directory after
      // the write
      currentDir = getCurrentDirectory();
      // change to path of name
      changeCurrentDirectory(path);
      // the target name should be without path, as we have changed
      // directory
      targetName = FileUtil.stripPath(name);
    }
    // store the file
    answer = doStoreFile(name, targetName, exchange);
  } finally {
    // change back to current directory if we changed directory
    if (currentDir != null) {
      changeCurrentDirectory(currentDir);
    }
  }
  return answer;
}

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

String onlyName = FileUtil.stripPath(fileName);
dummy.getIn().setHeader(Exchange.FILE_NAME, fileName);
dummy.getIn().setHeader(Exchange.FILE_NAME_ONLY, onlyName);

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

remoteName = FileUtil.stripPath(name);

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

targetName = FileUtil.stripPath(name);

相关文章