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(Collection<?> collection, String separator) 

Source Link

Document

Joins the elements of the provided Collection into a single String containing the provided elements.

Usage

From source file:MainClass.java

public static void main(String[] args) {
    //Join all Strings in the Array into a Single String, separated by $#$ 
    System.out.println(/*from ww w  . jav a2s .  com*/
            "7) Join Strings using separator >>>" + StringUtils.join(new String[] { "AB", "CD", "EF" }, "$#$"));
}

From source file:StringUtilsTrial.java

public static void main(String[] args) {

    // Join all Strings in the Array into a Single String, separated by $#$
    System.out.println(//from  w ww.j  av  a  2  s .c o  m
            "7) Join Strings using separator >>>" + StringUtils.join(new String[] { "AB", "CD", "EF" }, "$#$"));
}

From source file:com.prl.sort.InsertSort.java

/**
 * @param args// ww w.  j av  a 2 s  .c om
 */
public static void main(String[] args) {
    Integer[] arr = new Integer[10];
    Random random = new Random();
    int index = 0;
    while (true) {
        int num = random.nextInt(100) + 1;
        arr[index++] = num;
        if (index > 9) {
            break;
        }
    }

    System.out.println(StringUtils.join(arr, ","));

    int temp = 0;
    for (int i = 1; i < arr.length; i++) {
        int j = i - 1;
        temp = arr[i]; // ?
        // ???????
        for (; j >= 0 && arr[j] > temp; j--) {
            arr[j + 1] = arr[j];
            arr[j] = temp;
        }
    }

    System.out.println(StringUtils.join(arr, ","));
}

From source file:com.prl.sort.ShellSort.java

/**
 * @param args/*from ww  w .j  av a2s .  c o  m*/
 */
public static void main(String[] args) {
    Integer a[] = { 1, 54, 6, 3, 78, 34, 12, 45, 56, 100 };
    int m = a.length;
    int temp = 0;
    while (true) {
        m = (int) Math.ceil(m / 2);
        for (int i = 0; i < m; i++) {
            for (int x = i + m; x < i; x += m) {
                int j = i - m;
                temp = a[i];
                for (; j >= 0 && temp < a[j]; j -= m) {
                    a[j + m] = a[i];
                }
                temp = a[j + m];
            }
        }

        if (m == 1) {
            break;
        }
    }
    System.out.println(StringUtils.join(a, ","));
}

From source file:com.carteblanche.kwd.driver.KeywordDrivenDriver.java

public static void main(String[] args) {
    File[] listOfFiles;// w ww . j a v a  2s.  c o m

    File folder = new File(testDirectory + testSuiteName + "/");
    String testSuiteName = folder.getName();
    testSuiteName = StringUtils
            .capitalize(StringUtils.join(StringUtils.splitByCharacterTypeCamelCase(testSuiteName), ' '));
    listOfFiles = folder.listFiles();
    TestNGDriver testNGDriver = new TestNGDriver();

    int i = 0;
    for (File csv : listOfFiles) {
        KWDTestCase testCase = TestCaseParser.parse(csv, cvsSplitBy);
        testNGDriver.runTests(testCase, testSuiteName + i, folder.getName());
        i++;
    }

}

From source file:com.ms.commons.standalone.job.JobRunner.java

public static void main(String[] args) throws JobExecutionException {
    logger.error("__start of job, args is " + StringUtils.join(args, ", "));
    // try and catch everything
    try {/*w  w  w .  ja v a 2s.co m*/
        checkArgs(args);
        JobAction jobAction = JobAction.valueOf(args[0].trim());
        String fullClassName = args[1].trim();
        String[] NewArgs = getNewArgs(args);

        AbstractJob job = getJobInstanceByClassName(fullClassName);
        job.setArgs(NewArgs);

        clearStandaloneStopFile();

        switch (jobAction) {
        case start:
            job.execute(null);
            break;
        case startNohup:
            job.execute(null);
            break;
        case startWithDebug:
            job.execute(null);
            break;
        case stop:
            stopJob();
            break;
        default:
            throw new RuntimeException("jobAction must be start or stop");
        }
    } catch (Throwable t) {
        logger.error(t.getMessage(), t);
        t.printStackTrace();
    }
    logger.error("__end of job, args is " + StringUtils.join(args, ", "));
    System.exit(0);
}

From source file:com.world.watch.worldwatchcron.util.WWCron.java

public static void main(String[] args) {
    try {//  w  w  w .j  a  v a 2 s  . c o m
        WWCron cron = new WWCron();
        Map<String, Long> searchKeywords = cron.fetchKeywords();
        cron.populateLatestNews(searchKeywords);
        logger.debug("Latest news populated");
        cron.updateLatestNewsInParse();
        logger.debug("News updated in parse {}", StringUtils.join(cron.latestNews, ","));
        cron.sendPushToUsers();
        logger.debug("Pushed to users");
    } catch (ParseException ex) {
        logger.error("Parse Exception ", ex);
    }
}

From source file:CubaHSQLDBServer.java

public static void main(final String[] args) {
    final boolean validInit = args.length > 2;
    SwingUtilities.invokeLater(new Runnable() {
        @Override/*  ww w  .  j  a  v  a  2 s.com*/
        public void run() {
            final CubaHSQLDBServer monitor = new CubaHSQLDBServer();
            monitor.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
            monitor.setLocationRelativeTo(null);
            monitor.setVisible(true);

            if (validInit) {
                Integer dbPort = Integer.valueOf(args[0]);
                String dbPath = args[1];
                String dbName = args[2];
                final HSQLServer server = monitor.startServer(dbPort, dbPath, dbName);
                if (server != null) {
                    monitor.addWindowListener(new WindowAdapter() {
                        @Override
                        public void windowClosing(WindowEvent e) {
                            try {
                                server.shutdownCatalogs(2 /* NORMAL CLOSE MODE */);
                            } catch (RuntimeException exception) {
                                // Ignore exceptions from server.
                            }
                        }
                    });
                }
            } else {
                String argStr = StringUtils.join(args, ' ');
                monitor.setStatus(String.format(
                        "Invalid usage (args: '%s')\nExpected arguments: <port> <dbPath> <dbName>", argStr));
            }
        }
    });
}

From source file:edu.indiana.d2i.sloan.internal.DeleteVMSimulator.java

public static void main(String[] args) {
    DeleteVMSimulator simulator = new DeleteVMSimulator();

    CommandLineParser parser = new PosixParser();

    try {//from   w w  w  .j  a v a  2  s  .c o  m
        CommandLine line = simulator.parseCommandLine(parser, args);
        String wdir = line.getOptionValue(CMD_FLAG_VALUE.get(CMD_FLAG_KEY.WORKING_DIR));

        if (!HypervisorCmdSimulator.resourceExist(wdir)) {
            logger.error(String.format("Cannot find VM working dir: %s", wdir));
            System.exit(ERROR_CODE.get(ERROR_STATE.VM_NOT_EXIST));
        }

        Properties prop = new Properties();
        String filename = HypervisorCmdSimulator.cleanPath(wdir) + HypervisorCmdSimulator.VM_INFO_FILE_NAME;

        prop.load(new FileInputStream(new File(filename)));

        // cannot delete VM when it is not shutdown
        VMState currentState = VMState.valueOf(prop.getProperty(CMD_FLAG_VALUE.get(CMD_FLAG_KEY.VM_STATE)));

        if (!currentState.equals(VMState.SHUTDOWN)) {
            logger.error("Cannot perform delete when VM is not shutdown");
            System.exit(ERROR_CODE.get(ERROR_STATE.VM_NOT_SHUTDOWN));
        }

        // delete working directory
        FileUtils.deleteDirectory(new File(wdir));

        // success
        System.exit(0);

    } catch (ParseException e) {
        logger.error(String.format("Cannot parse input arguments: %s%n, expected:%n%s",
                StringUtils.join(args, " "), simulator.getUsage(100, "", 5, 5, "")));

        System.exit(ERROR_CODE.get(ERROR_STATE.INVALID_INPUT_ARGS));
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
        System.exit(ERROR_CODE.get(ERROR_STATE.IO_ERR));
    }

}

From source file:com.yahoo.flowetl.commons.runner.Main.java

/**
 * The main method entry point.//from w  w w  . jav  a  2 s  .  c o m
 */
public static void main(String[] args) throws Exception {
    if (args.length == 0) {
        System.out.println(
                Main.class.getSimpleName() + " [runner fully qualified java class name] arguments ...");
        return;
    }
    System.out.println("+Argument info:");
    StringBuilder argsStr = new StringBuilder();
    for (int i = 0; i < args.length; i++) {
        argsStr.append("(" + (i + 1) + ") " + args[i] + " [" + args[i].length() + " chars]");
        if (i + 1 != args.length) {
            argsStr.append(" ");
        }
    }
    System.out.println(argsStr);
    Map<String, Object> sysInfo = getRuntimeInfo();
    System.out.println("+Runtime info:");
    for (Entry<String, Object> e : sysInfo.entrySet()) {
        System.out.println("--- " + e.getKey() + " => " + (e.getValue() == null ? "" : e.getValue()));
    }
    String classToRun = args[0];
    Class<?> testToRun = KlassUtils.getClassForName(classToRun);
    if (KlassUtils.isAbstract(testToRun) || KlassUtils.isInterface(testToRun)) {
        System.out.println("+Runner class name that is not abstract or an interface is required!");
        return;
    }
    if (ClassUtils.isAssignable(testToRun, (Runner.class)) == false) {
        System.out.println("+Runner class name that is a instance/subclass of " + Runner.class.getSimpleName()
                + " is required!");
        return;
    }
    Class<Runner> rToRun = KlassUtils.getClassForName(classToRun);
    System.out.println("+Running program specified by runner class " + rToRun);
    Runner r = KlassUtils.getInstanceOf(rToRun, new Object[] {});
    String[] nargs = (String[]) ArrayUtils.subarray(args, 1, args.length);
    System.out.println("+Proxying to object " + r + " with arguments [" + StringUtils.join(nargs, ",") + "]");
    r.runProgram(nargs);
}