Example usage for org.apache.commons.lang StringUtils join

List of usage examples for org.apache.commons.lang StringUtils join

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils join.

Prototype

public static String join(Object[] array, String separator, int startIndex, int endIndex) 

Source Link

Document

Joins the elements of the provided array into a single String containing the provided list of elements.

Usage

From source file:de.tudarmstadt.ukp.dkpro.tc.ml.report.util.PrettyPrintUtils.java

/**
 * Pretty prints classifier name and arguments
 * /*from   w w w . j a v  a2s.c  o  m*/
 * @param classArgs
 *            a string with the classifier name as first comma separated token, followed by a
 *            list of arguments in angle brackets as provided by the discriminators.txt
 * @return a short name
 */
public static String prettyPrintClassifier(String classArgs) {
    String[] splittedArgs = classArgs.substring(1, classArgs.length() - 1).split(",");
    String classifierName = splittedArgs[0];
    String options = StringUtils.join(splittedArgs, "", 1, splittedArgs.length);
    return classifierName + options;
}

From source file:com.twitter.distributedlog.metadata.ZkMetadataResolver.java

@Override
public DLMetadata resolve(URI uri) throws IOException {
    String dlPath = uri.getPath();
    PathUtils.validatePath(dlPath);/*  w  w w .  j a v a  2  s .  com*/
    // Normal case the dl metadata is stored in the last segment
    // so lookup last segment first.
    String[] parts = StringUtils.split(dlPath, '/');
    if (null == parts || 0 == parts.length) {
        throw new IOException("Invalid dlPath to resolve dl metadata : " + dlPath);
    }
    for (int i = parts.length; i >= 0; i--) {
        String pathToResolve = String.format("/%s", StringUtils.join(parts, '/', 0, i));
        byte[] data;
        try {
            data = zkc.get().getData(pathToResolve, false, new Stat());
        } catch (KeeperException.NoNodeException nne) {
            continue;
        } catch (KeeperException ke) {
            throw new IOException("Fail to resolve dl path : " + pathToResolve);
        } catch (InterruptedException ie) {
            throw new IOException("Interrupted when resolving dl path : " + pathToResolve);
        }
        if (null == data || data.length == 0) {
            continue;
        }
        try {
            return DLMetadata.deserialize(uri, data);
        } catch (IOException ie) {
        }
    }
    throw new IOException("No bkdl config bound under dl path : " + dlPath);
}