List of usage examples for org.apache.commons.lang3 StringUtils chomp
public static String chomp(final String str)
Removes one newline from end of a String if it's there, otherwise leave it alone.
From source file:jp.ac.titech.cs.se.sparesort.Main.java
public static List<String> loadStringListFromFile(String path) throws Exception { List<String> events = new ArrayList<String>(); BufferedReader reader = new BufferedReader(new FileReader(path)); String line = null;// w w w . j a va 2s . c o m while ((line = reader.readLine()) != null) { events.add(StringUtils.chomp(line)); } reader.close(); return events; }
From source file:io.apiman.gateway.platforms.vertx3.api.auth.BasicAuth.java
private static AuthProvider authenticateBasic(JsonObject apimanConfig) { return (authInfo, resultHandler) -> { String storedUsername = apimanConfig.getString("username"); String storedPassword = apimanConfig.getString("password"); if (storedUsername == null || storedPassword == null) { resultHandler.handle(Future.failedFuture("Credentials not set in configuration.")); return; }/*from w w w . j a v a 2 s . c o m*/ String username = authInfo.getString("username"); String password = StringUtils.chomp(authInfo.getString("password")); if (storedUsername.equals(username) && storedPassword.equals(password)) { resultHandler.handle(Future.succeededFuture()); } else { resultHandler.handle(Future.failedFuture("No such user, or password incorrect.")); } }; }
From source file:io.fabric8.vertx.maven.plugin.utils.Prompter.java
public String prompt(String message, String defaultValue) { System.out.printf("%s (%s):", message, defaultValue); String input = StringUtils.chomp(scanner.nextLine()); if (StringUtils.isAnyBlank(input)) { return defaultValue; } else {// w w w.j a va 2s . com return input; } }
From source file:kenh.expl.functions.Chomp.java
public String process(String str) { return StringUtils.chomp(str); }
From source file:ch.cyberduck.core.ftp.LoggingProtocolCommandListener.java
@Override public void protocolCommandSent(final ProtocolCommandEvent event) { final String message = StringUtils.chomp(event.getMessage()); if (message.startsWith(FTPCmd.PASS.name())) { this.log(Type.request, String.format("%s %s", FTPCmd.PASS.name(), StringUtils.repeat("*", StringUtils.length(StringUtils.removeStart(message, FTPCmd.PASS.name()))))); } else {/*from w ww .ja v a 2 s . c o m*/ this.log(Type.request, message); } }
From source file:de.openali.odysseus.chart.factory.util.AxisUtils.java
/** * @return axis id from referencing type */// w w w .ja va2 s . co m public static String getIdentifier(final ReferencingType type) { if (type == null) { return null; } final String ref = type.getRef(); if (StringUtils.isNotEmpty(ref)) return ref; final String url = type.getUrl(); final RETokenizer tokenizer = new RETokenizer(new Pattern(".*#"), url); //$NON-NLS-1$ return StringUtils.chomp(tokenizer.nextToken()); }
From source file:ch.cyberduck.core.AbstractExceptionMappingService.java
public BackgroundException map(final String message, final T failure) { final BackgroundException exception = this.map(failure); final StringBuilder m = new StringBuilder(); this.append(m, StringUtils.chomp(LocaleFactory.localizedString(message, "Error"))); exception.setMessage(m.toString());//from w w w. j a v a 2 s.c o m return exception; }
From source file:ch.cyberduck.core.ftp.LoggingProtocolCommandListener.java
@Override public void protocolReplyReceived(final ProtocolCommandEvent event) { this.log(Type.response, StringUtils.chomp(event.getMessage())); }
From source file:ch.cyberduck.core.AbstractExceptionMappingService.java
public BackgroundException map(final String message, final T failure, final Path file) { final BackgroundException exception = this.map(failure); final StringBuilder m = new StringBuilder(); final String formatted = MessageFormat .format(StringUtils.chomp(LocaleFactory.localizedString(message, "Error")), file.getName()); if (StringUtils.contains(formatted, String.format("%s ", file.getName())) || StringUtils.contains(formatted, String.format(" %s", file.getName()))) { this.append(m, formatted); } else {//from w w w. ja v a 2 s .co m this.append(m, String.format("%s (%s)", MessageFormat.format(StringUtils.chomp(LocaleFactory.localizedString(message, "Error")), file.getName()), file.getAbsolute())); } exception.setMessage(m.toString()); exception.setFile(file); return exception; }
From source file:io.apiman.gateway.platforms.vertx3.verticles.ApiVerticle.java
public void authenticateBasic(JsonObject authInfo, Handler<AsyncResult<User>> resultHandler) { String username = authInfo.getString("username"); String password = StringUtils .chomp(Base64.encodeBase64String(DigestUtils.sha256(authInfo.getString("password")))); // Chomp, Digest, Base64Encode String storedPassword = apimanConfig.getBasicAuthCredentials().get(username); if (storedPassword != null && password.equals(storedPassword)) { resultHandler.handle(Future.<User>succeededFuture(null)); } else {/*from w w w . j av a2 s. co m*/ resultHandler.handle(Future.<User>failedFuture("Not such user, or password is incorrect.")); } }