Example usage for java.lang String equals

List of usage examples for java.lang String equals

Introduction

In this page you can find the example usage for java.lang String equals.

Prototype

public boolean equals(Object anObject) 

Source Link

Document

Compares this string to the specified object.

Usage

From source file:de.tudarmstadt.ukp.csniper.resbuild.stuff.BncCheckDocuments.java

public static void main(String[] args) throws IOException {
    boolean enabled = false;

    for (File f : FileUtils.listFiles(new File(BASE), new String[] { "xml" }, true)) {
        BufferedInputStream bis = null;
        try {/*from ww  w .j  a  v  a 2  s.  c  o  m*/
            bis = new BufferedInputStream(new FileInputStream(f));
            int c;
            StringBuilder sb = new StringBuilder();
            while ((c = bis.read()) != '>') {
                if (enabled) {
                    if (c == '"') {
                        enabled = false;
                        break;
                    } else {
                        sb.append((char) c);
                    }
                }
                if (c == '"') {
                    enabled = true;
                }
            }
            String name = f.getName().substring(0, 3);
            String id = sb.toString();
            if (!name.equals(id)) {
                System.out.println("Name is [" + name + "], but ID is [" + id + "].");
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            IOUtils.closeQuietly(bis);
        }
    }
}

From source file:com.tbodt.trp.TheRapidPermuter.java

/**
 * Main method for The Rapid Permuter./*from  w ww .j a va  2  s .  co m*/
 *
 * @param args
 * @throws IOException
 */
public static void main(String[] args) throws IOException {
    CommandProcessor.processCommand("\"\": remove(\"\") in([words])").ifPresent(x -> x.forEach(y -> {
    })); // to load all the classes we need

    try {
        cmd = new BasicParser().parse(options, args);
    } catch (ParseException ex) {
        System.err.println(ex.getMessage());
        return;
    }

    if (Arrays.asList(cmd.getOptions()).contains(help)) { // another way commons cli is severely broken
        new HelpFormatter().printHelp("trp", options);
        return;
    }

    if (cmd.hasOption('c'))
        doCommand(cmd.getOptionValue('c'));
    else {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        System.out.print("trp> ");
        String input;
        while ((input = in.readLine()) != null) {
            if (input.equals("exit"))
                return; // exit
            doCommand(input);
            System.out.print("trp> ");
        }
    }
}

From source file:net.orpiske.sas.service.main.Main.java

public static void main(String[] args) {
    int ret = 0;/*from   ww  w. j  a v  a 2 s .c om*/

    if (args.length == 0) {
        help(1);
    }

    try {
        ConfigurationWrapper.initConfiguration(Constants.SAS_SERVICE_CONFIG_DIR, Constants.CONFIG_FILE_NAME);
    } catch (ConfigurationException e) {
        System.err.println("Unable to load configuration file " + "'mdm-broker.properties': " + e.getMessage());

        System.exit(-1);
    } catch (FileNotFoundException e) {
        System.err.println("Unable to find configuration file " + "'mdm-broker.properties': " + e.getMessage());

        System.exit(-1);
    }

    String first = args[0];
    String[] newArgs = Arrays.copyOfRange(args, 1, args.length);

    if (first.equals("run")) {
        RunAction runAction = new RunAction(newArgs);

        ret = runAction.run();
        System.exit(ret);
    }

    help(-1);
}

From source file:Main.java

public static void main(String args[]) {
    String s1 = "Java2s.com";
    String s2 = "java2s.com";
    String s3 = "jAva2s.com";
    String s4 = "java2s.COM";
    System.out.println(s1 + " equals " + s2 + " -> " + s1.equals(s2));
    System.out.println(s1 + " equals " + s3 + " -> " + s1.equals(s3));
    System.out.println(s1 + " equals " + s4 + " -> " + s1.equals(s4));
}

From source file:net.orpiske.mdm.broker.main.Main.java

public static void main(String[] args) {
    int ret = 0;//w ww .  ja v a 2 s. com

    if (args.length == 0) {
        help(1);
    }

    try {
        ConfigurationWrapper.initConfiguration(Constants.MDM_BROKER_CONFIG_DIR, Constants.CONFIG_FILE_NAME);
    } catch (ConfigurationException e) {
        System.err.println("Unable to load configuration file " + "'mdm-broker.properties': " + e.getMessage());

        System.exit(-1);
    } catch (FileNotFoundException e) {
        System.err.println("Unable to find configuration file " + "'mdm-broker.properties': " + e.getMessage());

        System.exit(-1);
    }

    String first = args[0];
    String[] newArgs = Arrays.copyOfRange(args, 1, args.length);

    if (first.equals("run")) {
        RunAction runAction = new RunAction(newArgs);

        ret = runAction.run();
        System.exit(ret);
    }

    help(-1);
}

From source file:com.axiomine.largecollections.generator.GeneratorPrimitivePrimitive.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  a  2s .  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 KPACKAGE = args[2];
    //Package of your value serializer class. Use com.axiomine.bigcollections.functions
    String VPACKAGE = args[3];
    //Class name (no packages) of the Key class Ex. String
    String K = args[4];
    //Class name (no packages) of the value class Ex. Integer
    String V = args[5];

    String kCls = K;
    String vCls = V;

    if (kCls.equals("byte[]")) {
        kCls = "BytesArray";
    }
    if (vCls.equals("byte[]")) {
        vCls = "BytesArray";
    }

    String CLASS_NAME = kCls + vCls + "Map"; //Default
    //String templatePath = args[5];
    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/JavaLangBasedMapTemplate.java"));

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

        program = program.replaceAll("#CLASS_NAME#", CLASS_NAME);
        program = program.replaceAll("#K#", K);
        program = program.replaceAll("#V#", V);
        program = program.replaceAll("#KCLS#", kCls);
        program = program.replaceAll("#VCLS#", vCls);

        program = program.replaceAll("#KPACKAGE#", KPACKAGE);
        program = program.replaceAll("#VPACKAGE#", VPACKAGE);
        System.out.println(outFile.getAbsolutePath());
        FileUtils.writeStringToFile(outFile, program);
    }
}

From source file:com.axiomine.largecollections.generator.GeneratorWritableKeyPrimitiveValue.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 a2s.  com
    //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 KPACKAGE = args[2];
    //Package of your value serializer class. Use com.axiomine.bigcollections.functions
    String VPACKAGE = args[3];
    //Class name (no packages) of the Key class Ex. String
    String K = args[4];
    //Class name (no packages) of the value class Ex. Integer
    String V = args[5];
    String kCls = K;
    String vCls = V;

    if (kCls.equals("byte[]")) {
        kCls = "BytesArray";
    }
    if (vCls.equals("byte[]")) {
        vCls = "BytesArray";
    }

    String CLASS_NAME = kCls + vCls + "Map"; //Default

    //String templatePath = args[5];
    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/WritableKeyPrimitiveValueMapTemplate.java"));

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

        program = program.replaceAll("#CLASS_NAME#", CLASS_NAME);
        program = program.replaceAll("#K#", K);
        program = program.replaceAll("#V#", V);
        program = program.replaceAll("#KCLS#", kCls);
        program = program.replaceAll("#VCLS#", vCls);

        program = program.replaceAll("#KPACKAGE#", KPACKAGE);
        program = program.replaceAll("#VPACKAGE#", VPACKAGE);
        System.out.println(outFile.getAbsolutePath());
        FileUtils.writeStringToFile(outFile, program);
    }
}

From source file:com.axiomine.largecollections.generator.GeneratorWritableKeyWritableValue.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  a2s . 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 KPACKAGE = args[2];
    //Package of your value serializer class. Use com.axiomine.bigcollections.functions
    String VPACKAGE = args[3];
    //Class name (no packages) of the Key class Ex. String
    String K = args[4];
    //Class name (no packages) of the value class Ex. Integer
    String V = args[5];
    String kCls = K;
    String vCls = V;

    if (kCls.equals("byte[]")) {
        kCls = "BytesArray";
    }
    if (vCls.equals("byte[]")) {
        vCls = "BytesArray";
    }

    String CLASS_NAME = kCls + vCls + "Map"; //Default

    //String templatePath = args[5];
    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/WritableKeyWritableValueMapTemplate.java"));

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

        program = program.replaceAll("#CLASS_NAME#", CLASS_NAME);
        program = program.replaceAll("#K#", K);
        program = program.replaceAll("#V#", V);
        program = program.replaceAll("#KCLS#", kCls);
        program = program.replaceAll("#VCLS#", vCls);

        program = program.replaceAll("#KPACKAGE#", KPACKAGE);
        program = program.replaceAll("#VPACKAGE#", VPACKAGE);
        System.out.println(outFile.getAbsolutePath());
        FileUtils.writeStringToFile(outFile, program);
    }
}

From source file:com.axiomine.largecollections.generator.GeneratorPrimitiveKeyWritableValue.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  va 2 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 KPACKAGE = args[2];
    //Package of your value serializer class. Use com.axiomine.bigcollections.functions
    String VPACKAGE = args[3];
    //Class name (no packages) of the Key class Ex. String
    String K = args[4];
    //Class name (no packages) of the value class Ex. Integer
    String V = args[5];
    String vWritableCls = args[6];
    String kCls = K;
    String vCls = V;

    if (kCls.equals("byte[]")) {
        kCls = "BytesArray";
    }
    if (vCls.equals("byte[]")) {
        vCls = "BytesArray";
    }

    String CLASS_NAME = kCls + vCls + "Map"; //Default

    //String templatePath = args[5];
    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/PrimitiveKeyWritableValueMapTemplate.java"));

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

        program = program.replaceAll("#CLASS_NAME#", CLASS_NAME);
        program = program.replaceAll("#K#", K);
        program = program.replaceAll("#V#", V);
        program = program.replaceAll("#KCLS#", kCls);
        program = program.replaceAll("#VCLS#", vCls);
        program = program.replaceAll("#VWRITABLECLS#", vWritableCls);
        program = program.replaceAll("#KPACKAGE#", KPACKAGE);
        program = program.replaceAll("#VPACKAGE#", VPACKAGE);
        System.out.println(outFile.getAbsolutePath());
        FileUtils.writeStringToFile(outFile, program);
    }
}

From source file:com.act.lcms.ExtractFromNetCDFAroundMass.java

public static void main(String[] args) throws Exception {
    if (args.length != 4 || !args[0].endsWith(".nc")) {
        throw new RuntimeException(
                "Needs (1) NetCDF .nc file, " + "(2) mass value, e.g., 132.0772 for debugging, "
                        + "(3) how many timepoints to process (-1 for all), "
                        + "(4) prefix for .data and rendered .pdf, '-' for stdout");
    }//  w  ww .  j a  v a2s . c  o m

    String netCDF = args[0];
    Double mz = Double.parseDouble(args[1]);
    Integer numSpectraToProcess = Integer.parseInt(args[2]);
    String outPrefix = args[3];
    String outPDF = outPrefix.equals("-") ? null : outPrefix + ".pdf";
    String outDATA = outPrefix.equals("-") ? null : outPrefix + ".data";

    ExtractFromNetCDFAroundMass e = new ExtractFromNetCDFAroundMass();
    List<Triple<Double, Double, Double>> window = e.get2DWindow(netCDF, mz, numSpectraToProcess);

    // Write data output to outfile
    PrintStream whereTo = outDATA == null ? System.out : new PrintStream(new FileOutputStream(outDATA));
    for (Triple<Double, Double, Double> xyz : window) {
        whereTo.format("%.4f\t%.4f\t%.4f\n", xyz.getLeft(), xyz.getMiddle(), xyz.getRight());
        whereTo.flush();
    }

    if (outDATA != null) {
        // if outDATA is != null, then we have written to .data file
        // now render the .data to the corresponding .pdf file

        // first close the .data
        whereTo.close();

        // render outDATA to outPDF using gnuplo
        Gnuplotter plotter = new Gnuplotter();
        plotter.plot3D(outDATA, outPDF, netCDF, mz);
    }
}