本文整理了Java中org.apache.camel.util.FileUtil.stripTrailingSeparator()
方法的一些代码示例,展示了FileUtil.stripTrailingSeparator()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtil.stripTrailingSeparator()
方法的具体详情如下:
包路径:org.apache.camel.util.FileUtil
类名称:FileUtil
方法名:stripTrailingSeparator
暂无
代码示例来源:origin: org.apache.camel/camel-ftp
private boolean buildDirectoryChunks(String dirName) throws IOException {
final StringBuilder sb = new StringBuilder(dirName.length());
final String[] dirs = dirName.split("/|\\\\");
boolean success = false;
for (String dir : dirs) {
sb.append(dir).append('/');
// must normalize the directory name
String directory = endpoint.getConfiguration().normalizePath(sb.toString());
// do not try to build root folder (/ or \)
if (!(directory.equals("/") || directory.equals("\\"))) {
log.trace("Trying to build remote directory by chunk: {}", directory);
// while creating directory string if directory results in
// trailing slash, remove it not necessary
directory = FileUtil.stripTrailingSeparator(directory);
success = client.makeDirectory(directory);
}
}
return success;
}
代码示例来源:origin: io.syndesis/http-component
private static String buildUrl(String scheme, String hostname, Object port, String path, String uri) {
// build together from component level and given uri that has additional context path to append
String build = scheme + "://" + hostname;
if (port != null) {
build += ":" + port;
}
if (path != null) {
build = FileUtil.stripTrailingSeparator(build);
build += "/" + path;
}
String query = null;
if (uri != null && uri.contains("?")) {
query = StringHelper.after(uri, "?");
uri = StringHelper.before(uri, "?");
uri = StringHelper.after(uri, "://");
}
// remaining is to be appending
if (uri != null) {
build = FileUtil.stripTrailingSeparator(build);
build += "/" + uri;
}
if (query != null) {
build += "?" + query;
}
return build;
}
代码示例来源:origin: io.syndesis.connector/connector-component-http
private static String buildUrl(String scheme, String hostname, Object port, String path, String uri) {
// build together from component level and given uri that has additional context path to append
String build = scheme + "://" + hostname;
if (port != null) {
build += ":" + port;
}
if (path != null) {
build = FileUtil.stripTrailingSeparator(build);
build += "/" + path;
}
String query = null;
if (uri != null && uri.contains("?")) {
query = StringHelper.after(uri, "?");
uri = StringHelper.before(uri, "?");
uri = StringHelper.after(uri, "://");
}
// remaining is to be appending
if (uri != null) {
build = FileUtil.stripTrailingSeparator(build);
build += "/" + uri;
}
if (query != null) {
build += "?" + query;
}
return build;
}
代码示例来源:origin: org.apache.camel/camel-ftp
@Override
protected boolean pollDirectory(String fileName, List<GenericFile<SftpRemoteFile>> fileList, int depth) {
String currentDir = null;
if (isStepwise()) {
// must remember current dir so we stay in that directory after the poll
currentDir = operations.getCurrentDirectory();
}
// strip trailing slash
fileName = FileUtil.stripTrailingSeparator(fileName);
boolean answer = doPollDirectory(fileName, null, fileList, depth);
if (currentDir != null) {
operations.changeCurrentDirectory(currentDir);
}
return answer;
}
代码示例来源:origin: org.apache.camel/camel-ftp
@Override
protected boolean pollDirectory(String fileName, List<GenericFile<FTPFile>> fileList, int depth) {
String currentDir = null;
if (isStepwise()) {
// must remember current dir so we stay in that directory after the poll
currentDir = operations.getCurrentDirectory();
}
// strip trailing slash
fileName = FileUtil.stripTrailingSeparator(fileName);
boolean answer = doPollDirectory(fileName, null, fileList, depth);
if (currentDir != null) {
operations.changeCurrentDirectory(currentDir);
}
return answer;
}
代码示例来源:origin: org.apache.camel/camel-ftp
dirName = FileUtil.stripTrailingSeparator(dirName);
代码示例来源:origin: org.apache.camel/camel-netty-http
contextPath = FileUtil.stripTrailingSeparator(contextPath);
contextPath = FileUtil.stripLeadingSeparator(contextPath);
if (ObjectHelper.isNotEmpty(contextPath)) {
代码示例来源:origin: org.apache.camel/camel-ftp
dirName = FileUtil.stripTrailingSeparator(dirName);
代码示例来源:origin: org.apache.camel/camel-coap
contextPath = FileUtil.stripTrailingSeparator(contextPath);
contextPath = FileUtil.stripLeadingSeparator(contextPath);
if (ObjectHelper.isNotEmpty(contextPath)) {
代码示例来源:origin: org.apache.camel/camel-undertow
contextPath = FileUtil.stripTrailingSeparator(contextPath);
contextPath = FileUtil.stripLeadingSeparator(contextPath);
if (ObjectHelper.isNotEmpty(contextPath)) {
代码示例来源:origin: org.apache.camel/camel-ftp
String dir = FileUtil.stripTrailingSeparator(absolutePath);
String fileName = file.getName();
if (((FtpConfiguration) endpoint.getConfiguration()).isHandleDirectoryParserAbsoluteResult()) {
代码示例来源: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;
}
内容来源于网络,如有侵权,请联系作者删除!