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

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

Introduction

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

Prototype

public static boolean isBlank(String str) 

Source Link

Document

Checks if a String is whitespace, empty ("") or null.

Usage

From source file:Main.java

public static void main(String[] args) {
    String var1 = null;
    String var2 = "";
    String var3 = "    \t\t\t";
    String var4 = "Hello World";

    System.out.println("var1 is blank? = " + StringUtils.isBlank(var1));
    System.out.println("var2 is blank? = " + StringUtils.isBlank(var2));
    System.out.println("var3 is blank? = " + StringUtils.isBlank(var3));
    System.out.println("var4 is blank? = " + StringUtils.isBlank(var4));

    System.out.println("var1 is not blank? = " + StringUtils.isNotBlank(var1));
    System.out.println("var2 is not blank? = " + StringUtils.isNotBlank(var2));
    System.out.println("var3 is not blank? = " + StringUtils.isNotBlank(var3));
    System.out.println("var4 is not blank? = " + StringUtils.isNotBlank(var4));

    System.out.println("var1 is empty? = " + StringUtils.isEmpty(var1));
    System.out.println("var2 is empty? = " + StringUtils.isEmpty(var2));
    System.out.println("var3 is empty? = " + StringUtils.isEmpty(var3));
    System.out.println("var4 is empty? = " + StringUtils.isEmpty(var4));

    System.out.println("var1 is not empty? = " + StringUtils.isNotEmpty(var1));
    System.out.println("var2 is not empty? = " + StringUtils.isNotEmpty(var2));
    System.out.println("var3 is not empty? = " + StringUtils.isNotEmpty(var3));
    System.out.println("var4 is not empty? = " + StringUtils.isNotEmpty(var4));
}

From source file:Main.java

public static void main(String[] args) {
    String one = "";
    String two = "\t\r\n";
    String three = "     ";
    String four = null;//from  www .ja v  a 2  s .c  om
    String five = "four four two";

    // We can use StringUtils class for checking if a string is empty or not
    // using StringUtils.isBlank() method. This method will return true if
    // the tested string is empty, contains white space only or null.
    System.out.println("Is one empty? " + StringUtils.isBlank(one));
    System.out.println("Is two empty? " + StringUtils.isBlank(two));
    System.out.println("Is three empty? " + StringUtils.isBlank(three));
    System.out.println("Is four empty? " + StringUtils.isBlank(four));
    System.out.println("Is five empty? " + StringUtils.isBlank(five));

    // On the other side, the StringUtils.isNotBlank() methods complement
    // the previous method. It will check is a tested string is not empty.
    System.out.println("Is one not empty? " + StringUtils.isNotBlank(one));
    System.out.println("Is two not empty? " + StringUtils.isNotBlank(two));
    System.out.println("Is three not empty? " + StringUtils.isNotBlank(three));
    System.out.println("Is four not empty? " + StringUtils.isNotBlank(four));
    System.out.println("Is five not empty? " + StringUtils.isNotBlank(five));
}

From source file:gov.nih.nci.cabig.caaers.tools.ExcelImporter.java

public static void main(String[] args) {
    try {/*from  w  ww .ja v a 2  s.co m*/

        if (StringUtils.isBlank(args[0])) {
            System.out.println("Error::  Excel file not provided");
            System.out.println("Useage::  ant importexcel -Dfilelocation=<absolutefilepath>");
            return;
        }
        checkDsPropertiesExistence();
        String identity = "ANONYMOUS";
        String info = "importStudy";
        DataAuditInfo.setLocal(new DataAuditInfo(identity, "localhost", new Date(), info));
        File inputFile = new File(args[0]);
        ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext(
                getConfigLocations());
        ExcelProcessor excelProcessor = (ExcelProcessor) applicationContext.getBean("excelProcessor");
        excelProcessor.processExcel(inputFile);
    } catch (Exception ex) {
        System.out.println("\n Error occured: ");
        ex.printStackTrace();
    }
}

From source file:backtype.storm.command.list.java

/**
 * @param args// w  w  w.  j  a va2  s .co m
 */
public static void main(String[] args) {

    NimbusClient client = null;
    try {

        Map conf = Utils.readStormConfig();
        client = NimbusClient.getConfiguredClient(conf);

        if (args.length > 0 && StringUtils.isBlank(args[0]) == false) {
            String topologyName = args[0];
            TopologyInfo info = client.getClient().getTopologyInfoByName(topologyName);

            System.out.println("Successfully get topology info \n" + Utils.toPrettyJsonString(info));
        } else {
            ClusterSummary clusterSummary = client.getClient().getClusterInfo();

            System.out.println("Successfully get cluster info \n" + Utils.toPrettyJsonString(clusterSummary));
        }

    } catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
        throw new RuntimeException(e);
    } finally {
        if (client != null) {
            client.close();
        }
    }
}

From source file:com.haulmont.cuba.core.sys.utils.DbUpdaterUtil.java

public static void main(String[] args) {
    String property = System.getProperty("logback.configurationFile");
    if (StringUtils.isBlank(property)) {
        System.setProperty("logback.configurationFile", "com/haulmont/cuba/core/sys/utils/dbutil-logback.xml");
    }//w ww .j  ava  2s  .c  om

    DbUpdaterUtil runner = new DbUpdaterUtil();
    runner.execute(args);
}

From source file:at.tuwien.ifs.somtoolbox.apps.helper.VectorFileLabelLister.java

public static void main(String[] args) throws IOException {
    // register and parse all options
    JSAPResult config = OptionFactory.parseResults(args, OPTIONS);

    String inputVectorFileName = AbstractOptionFactory.getFilePath(config, "input");
    String outputFileName = AbstractOptionFactory.getFilePath(config, "output");

    PrintStream out;// w ww.  j a  v  a  2 s  . c  om
    if (StringUtils.isBlank(outputFileName)) {
        out = System.out;
    } else {
        out = new PrintStream(outputFileName);
    }

    InputData data = InputDataFactory.open(inputVectorFileName);
    String[] labels = data.getLabels();
    Arrays.sort(labels);
    for (String s : labels) {
        out.println(s);
    }
    out.close();
}

From source file:com.axiomine.largecollections.generator.GeneratorWritableSet.java

public static void main(String[] args) throws Exception {
    //Package of the new class you are generating Ex. com.mypackage
    String MY_PACKAGE = args[0];/*from ww w . j  ava  2s. c  o m*/
    //Any custom imports you need (: seperated). Use - if no custom imports are included
    //Ex. java.util.*:java.lang.Random     
    String CUSTOM_IMPORTS = args[1].equals("-") ? "" : args[1];
    //Package of your Key serializer class. Use com.axiomine.bigcollections.functions
    String T = args[2];

    String tCls = T;

    if (tCls.equals("byte[]")) {
        tCls = "BytesArray";
    }
    String CLASS_NAME = tCls + "Set";
    File root = new File("");
    File outFile = new File(root.getAbsolutePath() + "/src/main/java/" + MY_PACKAGE.replaceAll("\\.", "/") + "/"
            + CLASS_NAME + ".java");

    if (outFile.exists()) {
        System.out.println(outFile.getAbsolutePath() + " already exists. Please delete it and try again");
    }
    {
        String[] imports = null;
        String importStr = "";

        if (!StringUtils.isBlank(CUSTOM_IMPORTS)) {
            CUSTOM_IMPORTS.split(":");
            for (String s : imports) {
                importStr = "import " + s + ";\n";
            }
        }

        String program = FileUtils.readFileToString(
                new File(root.getAbsolutePath() + "/src/main/resources/WritableSetTemplate.java"));

        program = program.replaceAll("#MY_PACKAGE#", MY_PACKAGE);
        program = program.replaceAll("#CUSTOM_IMPORTS#", importStr);

        program = program.replaceAll("#CLASS_NAME#", CLASS_NAME);
        program = program.replaceAll("#T#", T);
        program = program.replaceAll("#TCLS#", tCls);

        System.out.println(outFile.getAbsolutePath());
        FileUtils.writeStringToFile(outFile, program);
    }
}

From source file:com.axiomine.largecollections.generator.GeneratorPrimitiveSet.java

public static void main(String[] args) throws Exception {
    //Package of the new class you are generating Ex. com.mypackage
    String MY_PACKAGE = args[0];//from  w  w w. j  a  v  a2s .  co  m
    //Any custom imports you need (: seperated). Use - if no custom imports are included
    //Ex. java.util.*:java.lang.Random     
    String CUSTOM_IMPORTS = args[1].equals("-") ? "" : args[1];
    //Package of your Key serializer class. Use com.axiomine.bigcollections.functions
    String T = args[2];

    String tCls = T;

    if (tCls.equals("byte[]")) {
        tCls = "BytesArray";
    }
    String CLASS_NAME = tCls + "Set";
    File root = new File("");
    File outFile = new File(root.getAbsolutePath() + "/src/main/java/" + MY_PACKAGE.replaceAll("\\.", "/") + "/"
            + CLASS_NAME + ".java");

    if (outFile.exists()) {
        System.out.println(outFile.getAbsolutePath() + " already exists. Please delete it and try again");
    }
    {
        String[] imports = null;
        String importStr = "";

        if (!StringUtils.isBlank(CUSTOM_IMPORTS)) {
            CUSTOM_IMPORTS.split(":");
            for (String s : imports) {
                importStr = "import " + s + ";\n";
            }
        }

        String program = FileUtils.readFileToString(
                new File(root.getAbsolutePath() + "/src/main/resources/PrimitiveSetTemplate.java"));

        program = program.replaceAll("#MY_PACKAGE#", MY_PACKAGE);
        program = program.replaceAll("#CUSTOM_IMPORTS#", importStr);

        program = program.replaceAll("#CLASS_NAME#", CLASS_NAME);
        program = program.replaceAll("#T#", T);
        program = program.replaceAll("#TCLS#", tCls);

        System.out.println(outFile.getAbsolutePath());
        FileUtils.writeStringToFile(outFile, program);
    }
}

From source file:com.axiomine.largecollections.generator.GeneratorWritableList.java

public static void main(String[] args) throws Exception {
    //Package of the new class you are generating Ex. com.mypackage
    String MY_PACKAGE = args[0];//from ww  w . j  a  v  a2 s  .c  om
    //Any custom imports you need (: seperated). Use - if no custom imports are included
    //Ex. java.util.*:java.lang.Random     
    String CUSTOM_IMPORTS = args[1].equals("-") ? "" : args[1];
    //Package of your Key serializer class. Use com.axiomine.bigcollections.functions
    String T = args[2];

    String tCls = T;

    if (tCls.equals("byte[]")) {
        tCls = "BytesArray";
    }
    String CLASS_NAME = tCls + "List";
    File root = new File("");
    File outFile = new File(root.getAbsolutePath() + "/src/main/java/" + MY_PACKAGE.replaceAll("\\.", "/") + "/"
            + CLASS_NAME + ".java");

    if (outFile.exists()) {
        System.out.println(outFile.getAbsolutePath() + " already exists. Please delete it and try again");
    }
    {
        String[] imports = null;
        String importStr = "";

        if (!StringUtils.isBlank(CUSTOM_IMPORTS)) {
            CUSTOM_IMPORTS.split(":");
            for (String s : imports) {
                importStr = "import " + s + ";\n";
            }
        }

        String program = FileUtils.readFileToString(
                new File(root.getAbsolutePath() + "/src/main/resources/WritableListTemplate.java"));

        program = program.replaceAll("#MY_PACKAGE#", MY_PACKAGE);
        program = program.replaceAll("#CUSTOM_IMPORTS#", importStr);

        program = program.replaceAll("#CLASS_NAME#", CLASS_NAME);
        program = program.replaceAll("#T#", T);
        program = program.replaceAll("#TCLS#", tCls);

        System.out.println(outFile.getAbsolutePath());
        FileUtils.writeStringToFile(outFile, program);
    }
}

From source file:com.axiomine.largecollections.generator.GeneratorPrimitiveList.java

public static void main(String[] args) throws Exception {
    //Package of the new class you are generating Ex. com.mypackage
    String MY_PACKAGE = args[0];/*from w  w  w.j  a v  a2 s.c  o  m*/
    //Any custom imports you need (: seperated). Use - if no custom imports are included
    //Ex. java.util.*:java.lang.Random     
    String CUSTOM_IMPORTS = args[1].equals("-") ? "" : args[1];
    //Package of your Key serializer class. Use com.axiomine.bigcollections.functions
    String T = args[2];

    String tCls = T;

    if (tCls.equals("byte[]")) {
        tCls = "BytesArray";
    }
    String CLASS_NAME = tCls + "List";
    File root = new File("");
    File outFile = new File(root.getAbsolutePath() + "/src/main/java/" + MY_PACKAGE.replaceAll("\\.", "/") + "/"
            + CLASS_NAME + ".java");

    if (outFile.exists()) {
        System.out.println(outFile.getAbsolutePath() + " already exists. Please delete it and try again");
    }
    {
        String[] imports = null;
        String importStr = "";

        if (!StringUtils.isBlank(CUSTOM_IMPORTS)) {
            CUSTOM_IMPORTS.split(":");
            for (String s : imports) {
                importStr = "import " + s + ";\n";
            }
        }

        String program = FileUtils.readFileToString(
                new File(root.getAbsolutePath() + "/src/main/resources/PrimitiveListTemplate.java"));

        program = program.replaceAll("#MY_PACKAGE#", MY_PACKAGE);
        program = program.replaceAll("#CUSTOM_IMPORTS#", importStr);

        program = program.replaceAll("#CLASS_NAME#", CLASS_NAME);
        program = program.replaceAll("#T#", T);
        program = program.replaceAll("#TCLS#", tCls);

        System.out.println(outFile.getAbsolutePath());
        FileUtils.writeStringToFile(outFile, program);
    }
}