Example usage for java.lang String contentEquals

List of usage examples for java.lang String contentEquals

Introduction

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

Prototype

public boolean contentEquals(CharSequence cs) 

Source Link

Document

Compares this string to the specified CharSequence .

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    String s1 = "s1";

    StringBuffer sbuf = new StringBuffer("a");
    boolean b = s1.contentEquals(sbuf);
}

From source file:Main.java

public static void main(String[] args) {

    String str1 = "java2s.com";
    String str2 = "java2s.com";

    StringBuffer strbuf = new StringBuffer(str1);
    System.out.println("Method returns : " + str2.contentEquals(strbuf));

    str2 = str1.toUpperCase();/*from ww  w .  j av  a 2s.  com*/
    System.out.println("Method returns : " + str2.contentEquals(strbuf));
}

From source file:Main.java

public static void main(String[] args) {

    String str1 = "java2s.com", str2 = "Java2s.com";
    CharSequence cs = "java2s.com";

    System.out.println("Method returns: " + str1.contentEquals("java2s.com"));

    System.out.println("Method returns: " + str1.contentEquals(cs));

    System.out.println("Method returns: " + str2.contentEquals("12345"));
}

From source file:net.sourceforge.users.dragomerlin.vcs2icsCalendarConverter.Main.java

public static void main(String[] args) throws IOException {

    // TODO: separate this into other method, in case we want to create a GUI later
    // TODO: give the user the choice, if export to single or multifile
    // TODO: write tests

    String email = null;//ww  w.ja  va 2  s .c o  m

    System.out.println("VCS to ICS calendar converter v" + Main.class.getPackage().getImplementationVersion());
    System.out.println("Working directory: " + System.getProperty("user.dir"));

    // Check whether Java has some bug causing bad quoted printable decoding
    // for non encoded characters
    String original_seq = "Steuererklr";
    String decoded_seq = ConvertSingleFile.decode(original_seq);
    if (original_seq.contentEquals(decoded_seq))
        System.out.println("org.apache.commons.codec.net.QuotedPrintableCodec.decodeQuotedPrintable\n"
                + " seems working ok on your system!\n");
    else
        System.out.println("\nWARNING:\n"
                + " org.apache.commons.codec.net.QuotedPrintableCodec.decodeQuotedPrintable\n"
                + " is not working properly on your system! Probably this is caused by a bug in Java.\n"
                + " Try using a diferent operating system or your resulting files may contain errors.\n");

    File workingdir = new File(System.getProperty("user.dir"));
    File dir_vcs = new File(System.getProperty("user.dir") + File.separator + "vcs" + File.separator);
    File dir_ics = new File(System.getProperty("user.dir") + File.separator + "ics" + File.separator);

    // Check if there are arguments for the jar file, and if there are, if
    // the first one
    // equals "--email" or "-e" and the second is somewhat valid, use it as
    // email.
    // If "--email" or "-e" was given but the following argument is missing
    // just don't ask any more.
    // Spaces are trimmed by the input automatically.

    // NOTE: Is a bad idea start reading the first argument first.
    // Instead start reading first the last argument to catch excepctions
    // and go down one by one.

    if (args.length > 0) {
        if ("-e".equals(args[0]) || "--email".equals(args[0])) {
            if (args.length > 1) {
                email = args[1];
            }
        } else {
            System.out.println("Invalid parameter: " + args[0]);
            System.out.println("Usage: java -jar calconv.jar [(-e | --email) email]");
            email = readEmail();
        }
    } else {
        email = readEmail();
    }

    // Check if VCS directory exists and is readable, create ICS dir if
    // needed and check that is writable.
    if (!dir_vcs.exists())
        System.out.println("The vcs directory doesn't exist. Create it and put into it the calendar files");
    if (!dir_vcs.canRead())
        System.out.println("The vcs directory is not readable");
    if (!workingdir.canWrite())
        System.out.println("The working dir is write protected. You can't write in this folder");
    if (!dir_ics.exists() && workingdir.canWrite())
        dir_ics.mkdir();
    if (!dir_ics.exists() || !dir_ics.canWrite())
        System.out.print("The ics dir does not exist or is not writable");
    if (dir_vcs.exists() && dir_vcs.canRead() && dir_ics.exists() && dir_ics.canWrite()) {
        File[] list = dir_vcs.listFiles(); // TODO use filenamefilter
        int vcs_counter = 0;
        ICSWriter icsWriter;
        if (true) { // TODO let user decide if single or multifile
            icsWriter = new ICSWriter(email);
        }
        for (int i = 0; i < list.length; i++) {
            if (list[i].isDirectory() && !list[i].isFile()) {
                // Check that is directory
                System.out.println("\"" + list[i].getName() + "\"" + " not valid, is a directory"
                        + System.getProperty("line.separator"));
            } else if (!list[i].getName().toLowerCase().endsWith(".vcs"))
                System.out.println("\"" + list[i].getName() + "\"" + " not valid file, is not VCS"
                        + System.getProperty("line.separator"));
            else {
                vcs_counter++;
                System.out.println("Found file: " + list[i].getAbsolutePath());
                // Start conversion here
                int numchars = list[i].getName().length();
                numchars = numchars - 4; // Remove .vcs from filenames
                File outFile = new File(dir_ics.toString() + File.separator
                        + list[i].getName().toString().substring(0, numchars) + ".ics");
                try {
                    if (false) { // TODO let user decide if single or multifile
                        icsWriter = new ICSWriter(email);
                    }
                    ConvertSingleFile.convert(list[i], email, icsWriter);

                    if (false) { // TODO let user decide if single or multifile
                        String contents = icsWriter.write(outFile);
                    }
                } catch (ParseException pe) {
                    System.out.println("Could not parse file " + list[i] + "Message was " + pe.getMessage());
                }
                // fileconverter.filetoUTF8(outFile);
            }
        }
        if (true) { // TODO let user decide if single or multifile
            icsWriter.write(new File(dir_ics.toString() + File.separator + "Result.ics"));
        }
        System.out.println("Found " + vcs_counter + " valid files");
        // System.out.println(java.nio.charset.Charset.defaultCharset().name());
    }
}

From source file:Main.java

public static boolean isValidName(String name) {
    return !name.contentEquals("");
}

From source file:Main.java

public static boolean isValidPassword(String password) {
    return !password.contentEquals("");
}

From source file:Main.java

public static boolean isLanguageOK(String x) {
    boolean rc = false;
    if (x.contentEquals("none"))
        return (true);
    File f = new File(
            "languagetool" + File.separator + "rules" + File.separator + x.substring(0, x.indexOf("_")));
    if (f.isDirectory())
        rc = true;//from   w w w. ja va 2 s . c o m
    return (rc);
}

From source file:com.njlabs.amrita.aid.util.Identifier.java

public static boolean isConnectedToAmrita(Context context) {
    WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    if (wifiManager != null) {
        String SSID = wifiManager.getConnectionInfo().getSSID().replace("\"", "").trim();
        return SSID.contentEquals("Amrita");
    }//from  w ww .  j a va  2  s. c  om
    return false;
}

From source file:com.albedinsky.android.support.intent.IntentBaseTest.java

static void assertBuildThrowsExceptionWithCause(BaseIntent intent, String cause) {
    try {/*from  ww  w. j a v a2  s.  com*/
        intent.build();
    } catch (AndroidRuntimeException e) {
        final String message = "Cannot build " + intent.getClass().getSimpleName() + ". " + cause;
        final String eMessage = e.getMessage();
        if (!message.contentEquals(eMessage)) {
            throw new AssertionError(
                    "Expected exception with message <" + message + "> but message was <" + eMessage + ">");
        }
        return;
    }
    final String intentName = intent.getClass().getSimpleName();
    throw new AssertionError("No exception has been thrown while building intent(" + intentName + ").");
}

From source file:nl.dtls.fairdatapoint.api.controller.utils.HttpHeadersUtils.java

public static RDFFormat getRequestedAcceptHeader(String contentType) {
    RDFFormat requesetedContentType = null;
    if (contentType == null || contentType.isEmpty()) {
        requesetedContentType = RDFFormat.TURTLE;
    } else if (contentType.contentEquals(RDFFormat.TURTLE.getDefaultMIMEType())
            || contentType.contains(MediaType.ALL_VALUE)) {
        requesetedContentType = RDFFormat.TURTLE;
    } else if (contentType.contentEquals(RDFFormat.JSONLD.getDefaultMIMEType())) {
        requesetedContentType = RDFFormat.JSONLD;
    } else if (contentType.contentEquals(RDFFormat.N3.getDefaultMIMEType())) {
        requesetedContentType = RDFFormat.N3;
    } else if (contentType.contentEquals(RDFFormat.RDFXML.getDefaultMIMEType())) {
        requesetedContentType = RDFFormat.RDFXML;
    }/*from w  w w. j  a  v a2s .com*/
    return requesetedContentType;
}