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) 

Source Link

Document

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

Usage

From source file:com.ms.commons.file.excel.ExcelParser.java

public static void main(String args[]) {
    HSSFWorkbook workBook = null;// www.ja va  2s  .  com
    File file = new File("/home/zxc/back_word/dump_word/33_2013_07_07.xls");
    InputStream excelDocumentStream = null;
    try {
        excelDocumentStream = new FileInputStream(file);
        POIFSFileSystem fsPOI = new POIFSFileSystem(new BufferedInputStream(excelDocumentStream));
        workBook = new HSSFWorkbook(fsPOI);
        ExcelParser parser = new ExcelParser(workBook.getSheetAt(0));
        String[] res;
        while ((res = parser.splitLine()) != null) {
            if (res.length == 7) {
                String resStr = StringUtils.join(res);
                if (resStr.contains("?")) {
                    continue;
                }
            }
            for (int i = 0; i < res.length; i++) {
                System.out.println("Token Found [" + res[i] + "]");
            }
        }
        excelDocumentStream.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.titankingdoms.dev.titanchat.format.Censor.java

/**
 * Filters the text for phrases and censors the phrases with the censor
 * /*  w  w w .  ja  va2 s  .c om*/
 * @param text The text to filter
 * 
 * @param phrases The phrases to censor
 * 
 * @param censor The censor to use
 * 
 * @return The filtered text
 */
public static String filter(String text, List<String> phrases, String censor) {
    if (text == null)
        return "";

    if (phrases == null)
        return text;

    if (censor == null)
        censor = "";

    StringBuffer filtered = new StringBuffer();

    String regex = "(" + StringUtils.join(phrases.toArray(new String[0])) + ")";

    Pattern phrasePattern = Pattern.compile(regex, Pattern.CASE_INSENSITIVE);
    Matcher match = phrasePattern.matcher(text);

    while (match.find())
        match.appendReplacement(filtered, Pattern.compile(".").matcher(match.group()).replaceAll(censor));

    return match.appendTail(filtered).toString();
}

From source file:com.alibaba.stonelab.toolkit.learning.cglib.Proxy.java

@Override
public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable {
    System.out.println(obj.getClass().getName() + ":" + StringUtils.join(args));
    Object ret = proxy.invokeSuper(obj, args);
    return ret;//  w ww . j  a  v  a  2  s.  c om
}

From source file:jp.co.ntts.vhut.exception.AigHasNoRappException.java

/**
 * @param aigIds Application Instance Group ?ID??
 * @param appId ????Application?ID/*w  w w.  j a  va  2s  .  c  om*/
 */
public AigHasNoRappException(Long[] aigIds, Long appId) {
    super("WSRVS5041", new Object[] { StringUtils.join(aigIds), appId });
    this.aigIds = aigIds;
    this.appId = appId;
}

From source file:jp.co.ntts.vhut.exception.CloudUserNotFoundException.java

/**
 * @param accounts ????????//from  w ww  .j  a  va  2  s .  com
 */
public CloudUserNotFoundException(String[] accounts) {
    super("WSRVS5051", new Object[] { StringUtils.join(accounts) });
    this.accounts = accounts;
}

From source file:com.uber.stream.kafka.mirrormaker.common.utils.ManagerRequestURLBuilder.java

public Request getHealthCheck() {
    String requestUrl = StringUtils.join(new String[] { _baseUrl, "/health" });

    Request request = new Request(Method.GET, requestUrl);
    return request;
}

From source file:com.intel.cosbench.driver.generator.NumericNameGenerator.java

@Override
public String next(Random random) {
    int value = generator.next(random);
    return StringUtils.join(new Object[] { prefix, value, suffix });
}

From source file:me.buildcarter8.FreedomOpMod.Commands.Command_ban.java

public boolean onCommand(CommandSender sender, Command cmd, String lbl, String[] args) {
    if (args.length > 2) {
        Player t = Bukkit.getPlayer(args[0]);
        String reason = StringUtils.join(args[1].split(" "));
        if (t == null) {
            sender.sendMessage("That player cannot be found!");
            return true;
        }//from   ww  w . ja  va2  s.c  o  m
        if (t == sender) {
            sender.sendMessage("Please, don't try to ban yourself.");
            return true;
        }
        if (FOP_AdminList.isAdmin(t)) {

            sender.sendMessage("That player is an admin, and cannot be banned. Use /fys for that.");
            sender.sendMessage("That player is an admin, and cannot be banned. Use /doom for that.");

            return true;
        }
        String name = t.getName().trim();
        String IP = t.getAddress().getAddress().getHostAddress().trim();

        FOP_Util.bcastMsg(name + " has been a VERY bad boy!");

        FOP_Util.bcastMsg(name + " has been a VERY naughty, naughty boy!");

        FOP_Util.adminAction(sender, "Banning: " + name + " and IP(s):" + IP);
        BanList.add(name, IP, reason, sender.getName());
        t.kickPlayer(reason + "\n" + "Banned by: " + sender.getName());
    }
    if (args.length == 1) {
        Player target = Bukkit.getPlayer(args[0]);
        String reason = "You have been temporarily banned from this server.\n" + "Banned by: " + sender.getName();
        if (target == null) {
            sender.sendMessage("That player cannot be found!");
            return true;
        }
        if (target == sender) {
            sender.sendMessage("Please, don't try to ban yourself.");
            return true;
        }
        if (FOP_AdminList.isAdmin(target)) {

            sender.sendMessage("That player is an admin, and cannot be banned. Use /fys instead.");

            sender.sendMessage("That player is an admin, and cannot be banned. Use /doom instead.");

            return true;
        }
        String name = target.getName().trim();
        String IP = target.getAddress().getAddress().getHostAddress().trim();

        FOP_Util.bcastMsg(name + " has been a VERY bad boy!");

        FOP_Util.bcastMsg(name + " has been a VERY bitchy boy!");

        FOP_Util.adminAction(sender, "Banning: " + name + " and IP(s): " + IP);
        BanList.add(name, IP, reason, sender.getName());
        target.kickPlayer(reason + "\n" + "Banned by: " + sender.getName());
    }
    else { return false; }
        
    return true;
}

From source file:com.intel.cosbench.driver.iterator.NumericNameIterator.java

@Override
public String next(String curr) {
    int value;/*  w ww.j  a  v a  2s. c o m*/
    if (StringUtils.isEmpty(curr)) {
        if ((value = iterator.next(0)) <= 0)
            return null;
        return StringUtils.join(new Object[] { prefix, value, suffix });
    }
    curr = StringUtils.removeStart(curr, prefix);
    curr = StringUtils.removeEnd(curr, suffix);
    if ((value = iterator.next(Integer.parseInt(curr))) <= 0)
        return null;
    return StringUtils.join(new Object[] { prefix, value, suffix });
}

From source file:com.uber.stream.kafka.mirrormaker.common.utils.ManagerRequestURLBuilder.java

public Request getTopicExternalViewRequestUrl(String topic) {
    String requestUrl = StringUtils.join(new String[] { _baseUrl, "/topics/", topic });

    Request request = new Request(Method.GET, requestUrl);
    return request;
}