Example usage for java.lang String toUpperCase

List of usage examples for java.lang String toUpperCase

Introduction

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

Prototype

public String toUpperCase() 

Source Link

Document

Converts all of the characters in this String to upper case using the rules of the default locale.

Usage

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();
    System.out.println("Method returns : " + str2.contentEquals(strbuf));
}

From source file:com.precioustech.fxtrading.oanda.restapi.marketdata.historic.HistoricMarketDataOnDemandDemo.java

public static void main(String[] args) throws Exception {
    usage(args);//from w w w . j a v a2  s . c o m
    final String url = args[0];
    final String accessToken = args[1];
    HistoricMarketDataProvider<String> historicMarketDataProvider = new OandaHistoricMarketDataProvider(url,
            accessToken);
    Scanner scanner = new Scanner(System.in);
    scanner.useDelimiter(System.getProperty("line.separator"));
    System.out.print("Instrument" + TradingConstants.COLON);
    String ccyPair = scanner.next();
    TradeableInstrument<String> instrument = new TradeableInstrument<>(ccyPair.toUpperCase());

    System.out.print(
            "Granularity" + ArrayUtils.toString(CandleStickGranularity.values()) + TradingConstants.COLON);
    CandleStickGranularity granularity = CandleStickGranularity.valueOf(scanner.next().toUpperCase());
    System.out.print("Time Range Candles(t) or Last N Candles(n)?:");
    String choice = scanner.next();

    List<CandleStick<String>> candles = null;
    if ("t".equalsIgnoreCase(choice)) {
        System.out.print("Start Time(" + datefmtLabel + ")" + TradingConstants.COLON);
        String startStr = scanner.next();
        Date startDt = sdf.parse(startStr);
        System.out.print("  End Time(" + datefmtLabel + ")" + TradingConstants.COLON);
        String endStr = scanner.next();
        Date endDt = sdf.parse(endStr);
        candles = historicMarketDataProvider.getCandleSticks(instrument, granularity,
                new DateTime(startDt.getTime()), new DateTime(endDt.getTime()));
    } else {
        System.out.print("Last how many candles?" + TradingConstants.COLON);
        int n = scanner.nextInt();
        candles = historicMarketDataProvider.getCandleSticks(instrument, granularity, n);
    }
    System.out.println(center("Time", timeColLen) + center("Open", priceColLen) + center("Close", priceColLen)
            + center("High", priceColLen) + center("Low", priceColLen));
    System.out.println(repeat("=", timeColLen + priceColLen * 4));
    for (CandleStick<String> candle : candles) {
        System.out.println(center(sdf.format(candle.getEventDate().toDate()), timeColLen)
                + formatPrice(candle.getOpenPrice()) + formatPrice(candle.getClosePrice())
                + formatPrice(candle.getHighPrice()) + formatPrice(candle.getLowPrice()));
    }
    scanner.close();
}

From source file:com.luqili.http.ssl.ClientCustomSSL.java

public final static void main(String[] args) throws Exception {
    String sslKeyStorePath = "/mnt/data2/clientkey/370900.pfx";
    String sslKeyStorePassword = "370900";
    String sslKeyStoreType = "PKCS12"; // JKS PKCS12
    String sslTrustStore = "/mnt/data2/clientkey/PengeSoftOARoot.cer";
    String sslTrustStorePassword = "";
    String url = "https://123.57.205.217:8082/Service/UpReportInfoServiceSvr.assx/UpReportInfo";
    String content = "Token=&CityCodes=370900&CountyCodes=&DealDate=2016-06-16T00:00:00&Reportor=?&NewBusinessArea=1000.88&NewBusinessAmount=9898&NewHouseArea=5000&NewHouseAmount=8000&NewHouseCount=20&OldReportor=?&OldBusinessArea=1234.56&OldBusinessAmount=80000&OldHouseArea=12580&OldHouseAmount=99999&OldHouseCount=100";
    // Trust own CA and all self-signed certs
    SSLContext sslcontext = SSLContexts.custom()
            .loadTrustMaterial(new File(sslKeyStorePath), sslKeyStorePassword.toCharArray(),
                    new TrustSelfSignedStrategy())
            .loadKeyMaterial(new File(sslKeyStorePath), sslKeyStorePassword.toCharArray(),
                    sslKeyStorePassword.toCharArray())
            .build();//  w w w  .  j  ava 2  s.  c o  m
    // Allow TLSv1 protocol only
    SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext, new String[] { "TLSv1" },
            null, SSLConnectionSocketFactory.getDefaultHostnameVerifier());
    CloseableHttpClient httpclient = HttpClients.custom().setSSLSocketFactory(sslsf).build();
    try {

        HttpPost httppost = new HttpPost(url);

        System.out.println("Executing request " + httppost.getRequestLine());

        CloseableHttpResponse response = httpclient.execute(httppost);
        try {
            HttpEntity entity = response.getEntity();
            if (entity != null) {
                String result = EntityUtils.toString(entity, "UTF-8").trim();
                if (!"True".toUpperCase().equals(result.toUpperCase())) {
                    System.out.println(result);
                }
            }

            System.out.println(response.getStatusLine());
            EntityUtils.consume(entity);
        } finally {
            response.close();
        }
    } finally {
        httpclient.close();
    }
}

From source file:in.sc.main.ABC.java

public static void main(String[] args) {
    List list = new ArrayList();
    list.add("1");
    list.add("2");
    list.add("3");
    Collections.reverse(list);//ww  w  .  ja va  2  s .co  m
    list.iterator();
    for (Object obj : reverse(list)) {
        System.out.print(obj + ", ");
    }

    D x = (D) new D();
    if (x instanceof I) {
        System.out.println("I");
    }
    if (x instanceof J) {
        System.out.println("J");
    }
    if (x instanceof C) {
        System.out.println("C");
    }
    if (x instanceof D) {
        System.out.println("D");
    }
    xyz x1 = new xyz("Test");
    int x2 = 111;

    Rank abc = Rank.FIRST;
    System.out.println("" + abc.SECOND);
    final int j = 2;
    switch (x2) {
    case 1:
        System.out.println("1");
        break;
    case 10:
        System.out.println("10");
        break;
    case j:
        System.out.println("2");
        break;
    case 5:
        System.out.println("5");
        break;
    default:
        System.out.println("Default");
        break;
    }
    String str1 = "lower", str2 = "LOWER", str3 = "UPPER";
    str1.toUpperCase();
    str1.replace("LOWER", "UPPER");
    System.out
            .println((str1.equals(str2)) + " " + (str1.equals(str3)) + "  " + str1 + "  " + str2 + "  " + str3);
    for (int i = 0; i < 3; i++) {
        System.out.println("" + i);
        switch (i) {
        case 0:
            break;
        case 1:
            System.out.println("one");
        case 2:
            System.out.println("two");
        case 3:
            System.out.println("three");
        }
    }
    System.out.println("done");
    ABC a = new ABC("a", "b");
    ABC b = new ABC(a);
}

From source file:MainClass.java

public static void main(String args[]) {
    String s1 = new String("hello");
    String s2 = new String("GOODBYE");
    String s3 = new String("   spaces   ");

    System.out.printf("s1 = %s\ns2 = %s\ns3 = %s\n\n", s1, s2, s3);

    // test toLowerCase and toUpperCase
    System.out.printf("s1.toUpperCase() = %s\n", s1.toUpperCase());
    System.out.printf("s2.toLowerCase() = %s\n\n", s2.toLowerCase());

}

From source file:MainClass.java

public static void main(String[] args) {
    String s1 = "abc";
    String s2 = "abc";
    String s3 = "def";

    if (s1 == s2)
        System.out.println("s1 == s2");

    if (s1 != s3)
        System.out.println("s1 != s3");

    if (s2 != s3)
        System.out.println("s2 != s3");

    String s4 = s1.toUpperCase();

    if (s4 != s1)
        System.out.println("s4 != s1");

    System.out.println("s1 = " + s1);
    System.out.println("s4 = " + s4);
}

From source file:at.newmedialab.ldpath.template.LDTemplate.java

public static void main(String[] args) {
    Options options = buildOptions();/* w w  w.j av  a 2  s.  com*/

    CommandLineParser parser = new PosixParser();
    try {
        CommandLine cmd = parser.parse(options, args);

        Level logLevel = Level.WARN;

        if (cmd.hasOption("loglevel")) {
            String logLevelName = cmd.getOptionValue("loglevel");
            if ("DEBUG".equals(logLevelName.toUpperCase())) {
                logLevel = Level.DEBUG;
            } else if ("INFO".equals(logLevelName.toUpperCase())) {
                logLevel = Level.INFO;
            } else if ("WARN".equals(logLevelName.toUpperCase())) {
                logLevel = Level.WARN;
            } else if ("ERROR".equals(logLevelName.toUpperCase())) {
                logLevel = Level.ERROR;
            } else {
                log.error("unsupported log level: {}", logLevelName);
            }
        }

        if (logLevel != null) {
            for (String logname : new String[] { "at", "org", "net", "com" }) {

                ch.qos.logback.classic.Logger logger = (ch.qos.logback.classic.Logger) LoggerFactory
                        .getLogger(logname);
                logger.setLevel(logLevel);
            }
        }

        File template = null;
        if (cmd.hasOption("template")) {
            template = new File(cmd.getOptionValue("template"));
        }

        GenericSesameBackend backend;
        if (cmd.hasOption("store")) {
            backend = new LDPersistentBackend(new File(cmd.getOptionValue("store")));
        } else {
            backend = new LDMemoryBackend();
        }

        Resource context = null;
        if (cmd.hasOption("context")) {
            context = backend.getRepository().getValueFactory().createURI(cmd.getOptionValue("context"));
        }

        BufferedWriter out = null;
        if (cmd.hasOption("out")) {
            File of = new File(cmd.getOptionValue("out"));
            if (of.canWrite()) {
                out = new BufferedWriter(new FileWriter(of));
            } else {
                log.error("cannot write to output file {}", of);
                System.exit(1);
            }
        } else {
            out = new BufferedWriter(new OutputStreamWriter(System.out));
        }

        if (backend != null && context != null && template != null) {
            TemplateEngine<Value> engine = new TemplateEngine<Value>(backend);

            engine.setDirectoryForTemplateLoading(template.getParentFile());
            engine.processFileTemplate(context, template.getName(), out);
            out.flush();
            out.close();
        }

        if (backend instanceof LDPersistentBackend) {
            ((LDPersistentBackend) backend).shutdown();
        }

    } catch (ParseException e) {
        System.err.println("invalid arguments");
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("LDQuery", options, true);
    } catch (FileNotFoundException e) {
        System.err.println("file or program could not be found");
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("LDQuery", options, true);
    } catch (IOException e) {
        System.err.println("could not access file");
        e.printStackTrace(System.err);
    } catch (TemplateException e) {
        System.err.println("error while processing template");
        e.printStackTrace(System.err);
    }

}

From source file:at.newmedialab.ldpath.backend.linkeddata.LDQuery.java

public static void main(String[] args) {
    Options options = buildOptions();/*from   www.  ja va  2 s  .  com*/

    CommandLineParser parser = new PosixParser();
    try {
        CommandLine cmd = parser.parse(options, args);

        Level logLevel = Level.WARN;

        if (cmd.hasOption("loglevel")) {
            String logLevelName = cmd.getOptionValue("loglevel");
            if ("DEBUG".equals(logLevelName.toUpperCase())) {
                logLevel = Level.DEBUG;
            } else if ("INFO".equals(logLevelName.toUpperCase())) {
                logLevel = Level.INFO;
            } else if ("WARN".equals(logLevelName.toUpperCase())) {
                logLevel = Level.WARN;
            } else if ("ERROR".equals(logLevelName.toUpperCase())) {
                logLevel = Level.ERROR;
            } else {
                log.error("unsupported log level: {}", logLevelName);
            }
        }

        if (logLevel != null) {
            for (String logname : new String[] { "at", "org", "net", "com" }) {

                ch.qos.logback.classic.Logger logger = (ch.qos.logback.classic.Logger) LoggerFactory
                        .getLogger(logname);
                logger.setLevel(logLevel);
            }
        }

        String format = null;
        if (cmd.hasOption("format")) {
            format = cmd.getOptionValue("format");
        }

        GenericSesameBackend backend;
        if (cmd.hasOption("store")) {
            backend = new LDPersistentBackend(new File(cmd.getOptionValue("store")));
        } else {
            backend = new LDMemoryBackend();
        }

        Resource context = null;
        if (cmd.hasOption("context")) {
            context = backend.getRepository().getValueFactory().createURI(cmd.getOptionValue("context"));
        }

        if (backend != null && context != null) {
            LDPath<Value> ldpath = new LDPath<Value>(backend);

            if (cmd.hasOption("path")) {
                String path = cmd.getOptionValue("path");

                for (Value v : ldpath.pathQuery(context, path, null)) {
                    System.out.println(v.stringValue());
                }
            } else if (cmd.hasOption("program")) {
                File file = new File(cmd.getOptionValue("program"));

                Map<String, Collection<?>> result = ldpath.programQuery(context, new FileReader(file));

                for (String field : result.keySet()) {
                    StringBuilder line = new StringBuilder();
                    line.append(field);
                    line.append(" = ");
                    line.append("{");
                    for (Iterator it = result.get(field).iterator(); it.hasNext();) {
                        line.append(it.next().toString());
                        if (it.hasNext()) {
                            line.append(", ");
                        }
                    }
                    line.append("}");
                    System.out.println(line);

                }
            }
        }

        if (backend instanceof LDPersistentBackend) {
            ((LDPersistentBackend) backend).shutdown();
        }

    } catch (ParseException e) {
        System.err.println("invalid arguments");
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("LDQuery", options, true);
    } catch (LDPathParseException e) {
        System.err.println("path or program could not be parsed");
        e.printStackTrace();
    } catch (FileNotFoundException e) {
        System.err.println("file or program could not be found");
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("LDQuery", options, true);
    } catch (IOException e) {
        System.err.println("could not access cache data directory");
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("LDQuery", options, true);
    }

}

From source file:baldrickv.s3streamingtool.S3StreamingTool.java

public static void main(String args[]) throws Exception {
    BasicParser p = new BasicParser();

    Options o = getOptions();/*ww  w  .  java2 s  .  c om*/

    CommandLine cl = p.parse(o, args);

    if (cl.hasOption('h')) {
        HelpFormatter hf = new HelpFormatter();
        hf.setWidth(80);

        StringBuilder sb = new StringBuilder();

        sb.append("\n");
        sb.append("Upload:\n");
        sb.append("    -u -r creds -s 50M -b my_bucket -f hda1.dump -t 10\n");
        sb.append("Download:\n");
        sb.append("    -d -r creds -s 50M -b my_bucket -f hda1.dump -t 10\n");
        sb.append("Upload encrypted:\n");
        sb.append("    -u -r creds -z -k secret_key -s 50M -b my_bucket -f hda1.dump -t 10\n");
        sb.append("Download encrypted:\n");
        sb.append("    -d -r creds -z -k secret_key -s 50M -b my_bucket -f hda1.dump -t 10\n");
        sb.append("Cleanup in-progress multipart uploads\n");
        sb.append("    -c -r creds -b my_bucket\n");
        System.out.println(sb.toString());

        hf.printHelp("See above", o);

        return;
    }

    int n = 0;
    if (cl.hasOption('d'))
        n++;
    if (cl.hasOption('u'))
        n++;
    if (cl.hasOption('c'))
        n++;
    if (cl.hasOption('m'))
        n++;

    if (n != 1) {
        System.err.println("Must specify at exactly one of -d, -u, -c or -m");
        System.exit(-1);
    }

    if (cl.hasOption('m')) {
        //InputStream in = new java.io.BufferedInputStream(System.in,1024*1024*2);
        InputStream in = System.in;
        System.out.println(TreeHashGenerator.calculateTreeHash(in));
        return;
    }

    require(cl, 'b');

    if (cl.hasOption('d') || cl.hasOption('u')) {
        require(cl, 'f');
    }
    if (cl.hasOption('z')) {
        require(cl, 'k');
    }

    AWSCredentials creds = null;

    if (cl.hasOption('r')) {
        creds = Utils.loadAWSCredentails(cl.getOptionValue('r'));
    } else {
        if (cl.hasOption('i') && cl.hasOption('e')) {
            creds = new BasicAWSCredentials(cl.getOptionValue('i'), cl.getOptionValue('e'));
        } else {

            System.out.println("Must specify either credential file (-r) or AWS key ID and secret (-i and -e)");
            System.exit(-1);
        }
    }

    S3StreamConfig config = new S3StreamConfig();
    config.setEncryption(false);
    if (cl.hasOption('z')) {
        config.setEncryption(true);
        config.setSecretKey(Utils.loadSecretKey(cl.getOptionValue("k")));
    }

    if (cl.hasOption("encryption-mode")) {
        config.setEncryptionMode(cl.getOptionValue("encryption-mode"));
    }
    config.setS3Bucket(cl.getOptionValue("bucket"));
    if (cl.hasOption("file")) {
        config.setS3File(cl.getOptionValue("file"));
    }

    if (cl.hasOption("threads")) {
        config.setIOThreads(Integer.parseInt(cl.getOptionValue("threads")));
    }

    if (cl.hasOption("blocksize")) {
        String s = cl.getOptionValue("blocksize");
        s = s.toUpperCase();
        int multi = 1;

        int end = 0;
        while ((end < s.length()) && (s.charAt(end) >= '0') && (s.charAt(end) <= '9')) {
            end++;
        }
        int size = Integer.parseInt(s.substring(0, end));

        if (end < s.length()) {
            String m = s.substring(end);
            if (m.equals("K"))
                multi = 1024;
            else if (m.equals("M"))
                multi = 1048576;
            else if (m.equals("G"))
                multi = 1024 * 1024 * 1024;
            else if (m.equals("KB"))
                multi = 1024;
            else if (m.equals("MB"))
                multi = 1048576;
            else if (m.equals("GB"))
                multi = 1024 * 1024 * 1024;
            else {
                System.out.println("Unknown suffix on block size.  Only K,M and G understood.");
                System.exit(-1);
            }

        }
        size *= multi;
        config.setBlockSize(size);
    }

    Logger.getLogger("").setLevel(Level.FINE);

    S3StreamingDownload.log.setLevel(Level.FINE);
    S3StreamingUpload.log.setLevel(Level.FINE);

    config.setS3Client(new AmazonS3Client(creds));
    config.setGlacierClient(new AmazonGlacierClient(creds));
    config.getGlacierClient().setEndpoint("glacier.us-west-2.amazonaws.com");

    if (cl.hasOption("glacier")) {
        config.setGlacier(true);
        config.setStorageInterface(new StorageGlacier(config.getGlacierClient()));
    } else {
        config.setStorageInterface(new StorageS3(config.getS3Client()));
    }
    if (cl.hasOption("bwlimit")) {
        config.setMaxBytesPerSecond(Double.parseDouble(cl.getOptionValue("bwlimit")));

    }

    if (cl.hasOption('c')) {
        if (config.getGlacier()) {
            GlacierCleanupMultipart.cleanup(config);
        } else {
            S3CleanupMultipart.cleanup(config);
        }
        return;
    }
    if (cl.hasOption('d')) {
        config.setOutputStream(System.out);
        S3StreamingDownload.download(config);
        return;
    }
    if (cl.hasOption('u')) {
        config.setInputStream(System.in);
        S3StreamingUpload.upload(config);
        return;
    }

}

From source file:hk.hku.cecid.corvus.http.AS2EnvelopQuerySender.java

/**
 * The main method is for CLI mode.//from w  w w. j  av a 2s  .c o m
 */
public static void main(String[] args) {
    try {
        java.io.PrintStream out = System.out;

        if (args.length < 2) {
            out.println("Usage: as2-envelop [config-xml] [log-path]");
            out.println();
            out.println("Example: as2-envelop ./config/as2-envelop/as2-request.xml ./logs/as2-envelop.log");
            System.exit(1);
        }

        out.println("------------------------------------------------------");
        out.println("       AS2 Envelop Queryer       ");
        out.println("------------------------------------------------------");

        // Initialize the logger.
        out.println("Initialize logger .. ");
        // The logger path is specified at the last argument.
        FileLogger logger = new FileLogger(new File(args[args.length - 1]));

        // Initialize the query parameter.
        out.println("Importing AS2 administrative sending parameters ... ");
        AS2AdminData acd = DataFactory.getInstance()
                .createAS2AdminDataFromXML(new PropertyTree(new File(args[0]).toURI().toURL()));

        boolean historyQueryNeeded = false;
        AS2MessageHistoryRequestData queryData = new AS2MessageHistoryRequestData();
        if (acd.getMessageIdCriteria() == null || acd.getMessageIdCriteria().trim().equals("")) {

            historyQueryNeeded = true;

            // print command prompt
            out.println("No messageID was specified!");
            out.println("Start querying message repositry ...");

            String endpoint = acd.getEnvelopQueryEndpoint();
            String host = endpoint.substring(0, endpoint.indexOf("/corvus"));
            host += "/corvus/httpd/as2/msg_history";
            queryData.setEndPoint(host);
        } /*
            If the user has entered message id but no messagebox, 
            using the messageid as serach criteria and as 
            user to chose his target message
          */
        else if (acd.getMessageBoxCriteria() == null || acd.getMessageBoxCriteria().trim().equals("")) {

            historyQueryNeeded = true;

            // print command prompt
            out.println("Message Box value haven't specified.");
            out.println("Start query message whcih matched with messageID: " + acd.getMessageIdCriteria());

            String endpoint = acd.getEnvelopQueryEndpoint();
            String host = endpoint.substring(0, endpoint.indexOf("/corvus"));
            host += "/corvus/httpd/as2/msg_history";

            queryData.setEndPoint(host);
            queryData.setMessageId(acd.getMessageIdCriteria());
        }
        //Debug Message
        System.out.println("history Endpoint: " + queryData.getEndPoint());
        System.out.println("Repositry Endpoint: " + acd.getEnvelopQueryEndpoint());

        if (historyQueryNeeded) {
            List msgList = listAvailableMessage(queryData, logger);

            if (msgList == null || msgList.size() == 0) {
                out.println();
                out.println();
                out.println("No stream data found in repositry...");
                out.println("Please view log for details .. ");
                return;
            }

            int selection = promptForSelection(msgList);

            if (selection == -1) {
                return;
            }

            String messageID = (String) ((List) msgList.get(selection)).get(0);
            String messageBox = (String) ((List) msgList.get(selection)).get(1);
            acd.setMessageIdCriteria(messageID);
            acd.setMessageBoxCriteria(messageBox.toUpperCase());
            out.println();
            out.println();
            out.println("Start download targeted message envelop ...");
        }

        // Initialize the sender.
        out.println("Initialize AS2 HTTP data service client... ");
        AS2EnvelopQuerySender sender = new AS2EnvelopQuerySender(logger, acd);

        out.println("Sending    AS2 HTTP Envelop Query request ... ");
        sender.run();

        out.println();
        out.println("                    Sending Done:                   ");
        out.println("----------------------------------------------------");
        out.println("The Message Envelope : ");
        InputStream eins = sender.getEnvelopStream();
        if (eins.available() == 0) {
            out.println("No stream data found.");
            out.println("The message envelop does not exist for message id " + sender.getMessageIdToDownload()
                    + " and message box " + sender.getMessageBoxToDownload());
        } else
            IOHandler.pipe(sender.getEnvelopStream(), out);

        out.println("Please view log for details .. ");
    } catch (Exception e) {
        e.printStackTrace(System.err);
    }
}