Example usage for java.lang String toLowerCase

List of usage examples for java.lang String toLowerCase

Introduction

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

Prototype

public String toLowerCase() 

Source Link

Document

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

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    String string = "This is a test";
    // Convert to upper case
    String upper = string.toUpperCase();

    // Convert to lower case
    String lower = string.toLowerCase();
}

From source file:WriteIndex.java

/**
 * @param args/*  w  ww  . j  a  v a2 s  .  c o  m*/
 */
public static void main(String[] args) throws IOException {

    File docs = new File("documents");
    File indexDir = new File(INDEX_DIRECTORY);

    Directory directory = FSDirectory.open(indexDir);

    Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_35);
    IndexWriterConfig conf = new IndexWriterConfig(Version.LUCENE_35, analyzer);
    IndexWriter writer = new IndexWriter(directory, conf);
    writer.deleteAll();

    for (File file : docs.listFiles()) {
        Metadata metadata = new Metadata();
        ContentHandler handler = new BodyContentHandler();
        ParseContext context = new ParseContext();
        Parser parser = new AutoDetectParser();
        InputStream stream = new FileInputStream(file);
        try {
            parser.parse(stream, handler, metadata, context);
        } catch (TikaException e) {
            e.printStackTrace();
        } catch (SAXException e) {
            e.printStackTrace();
        } finally {
            stream.close();
        }

        String text = handler.toString();
        String fileName = file.getName();

        Document doc = new Document();
        doc.add(new Field("file", fileName, Store.YES, Index.NO));

        for (String key : metadata.names()) {
            String name = key.toLowerCase();
            String value = metadata.get(key);

            if (StringUtils.isBlank(value)) {
                continue;
            }

            if ("keywords".equalsIgnoreCase(key)) {
                for (String keyword : value.split(",?(\\s+)")) {
                    doc.add(new Field(name, keyword, Store.YES, Index.NOT_ANALYZED));
                }
            } else if ("title".equalsIgnoreCase(key)) {
                doc.add(new Field(name, value, Store.YES, Index.ANALYZED));
            } else {
                doc.add(new Field(name, fileName, Store.YES, Index.NOT_ANALYZED));
            }
        }
        doc.add(new Field("text", text, Store.NO, Index.ANALYZED));
        writer.addDocument(doc);

    }

    writer.commit();
    writer.deleteUnusedFiles();

    System.out.println(writer.maxDoc() + " documents written");
}

From source file:lrnneval.LRNNeval.java

public static void main(String[] args) {
    sampleStore = loadSampleStore("786_0_avg.ser");
    Global.uncompressedLambda = true;/*from ww  w .  ja va 2  s.c o m*/

    try {
        String err = args[0];
        if (err.toLowerCase().equals("acc")) {
            errorMeasure = Error.acc;
        } else if (err.toLowerCase().equals("mse")) {
            errorMeasure = Error.mse;
        } else if (err.toLowerCase().equals("ace")) {
            errorMeasure = Error.ace;
        } else if (err.toLowerCase().equals("all")) {
            errorMeasure = Error.all;
        }
    } catch (Exception ex) {
        {
            System.out.println(
                    "invalid error measure argument, type only one of the four {acc,mse,ace,all}, setting default all");
            errorMeasure = Error.all;
        }
    }

    CommandLine cmd = parseArguments(new String[] { "-e", "n", "-r", "n", "-gr", "avg" });
    if (cmd == null) {
        return;
    }

    Main.setParameters(cmd);

    System.out.println("Successfully started the server with GROUNDING : " + "avg" + " and ERROR MEASURE : "
            + errorMeasure);

    //these are good weights for avg
    //String weights = "-0.9249754407553773,-0.9439484477283224,-1.4013522849823807,-0.9598978367657336,-0.4754250401146353,-1.7932462469657462,-1.2304729052748857,-1.2184932625697396,-2.829880202442235,0.4364598420280804,0.6376859875085558,-0.019436009946223222,0.498418782159168,0.6443247902888757,-0.3343447708895524,0.23897592644029247,-0.24124867520962723,-2.1524763687129775,3.877419358076544,3.3942225360835994,2.1543401552849883,3.0020089756435726,1.9822636950855645,2.4258443761454407,2.181033774000903,1.5080712098278846,0.47121142912505326,-1.1910685015297822,-0.3126868998695382,-0.02594375357781614,-0.32023216018349976,0.9625375043815988,-0.25436320486378555,0.013798031217081154,-0.20704101807950667,-1.1276740925422055,-0.1712157973654618,0.4096560129723409,0.2144032251321008,0.48510698466847313,1.2481870339553933,-0.003816236263597251,0.2032733438466816,0.024098089433525798,-0.955109609821293,1.5901764458269492,1.0463870261534285,1.2427149426506732,2.0581649541065326,1.153571431178797,0.8425985039864509,1.133175079871852,0.9850076240334972,0.436024182046061,0.7190442151869768,-0.6949744631672836,-1.3430293792031873,-0.8382932114774597,-0.8812384831575061,-0.10951752672865002,-1.2898627648305097,0.010040647478972918,1.9313004278675505,-2.0532819834427856,-1.611206101091242,-0.81093210318517,-1.6337332520419554,-0.9692838147240456,-0.3620702982252171,-1.4349421599753591,-0.31167693021378456,0.9745841925361296,0.07306098439755142,-0.6030481073042927,-0.9993957903357078,-0.8571877358520659,-0.8078594375954147,0.1504763167884256,-1.2788440840199118,0.25585818961727885,1.4121993837323314,-0.15931261321080603,0.6845874567920014,0.07711368629736551,0.5082716045370803,0.7147641776397765,-0.17118391143362202,0.18786949862321997,-0.2010442397965025,-2.1246434206632543,0.9619787830051358,0.8552839253309095,0.4921366886459156,0.8326639480031317,0.5225521938448122,0.5499426638803808,0.6399368251526891,-0.011260411597728287,-0.9982696782791805,2.2152522302494893,1.3342692111104495,1.3763426988243384,1.5451270874203673,0.9335145587844418,0.9111689060673769,0.8798703018494632,0.8152825208960369,0.40008489832827493,-0.11490326441913883,0.39577240982195694,0.15695201840742234,0.5602973811598536,0.43076973440896454,0.6710280725842391,0.39631968347280677,0.005348415687521984,-0.9937998838528831,0.6703828712900466,0.48985841758795706,0.47137395272743826,0.3011624570740844,0.2738978444853426,0.2811251964576915,0.1849097044696144,0.6823507200639191,-0.47835211698301305,1.4572377548221165,0.6950840960955923,0.6614817509928316,0.6673177143530127,0.6130158898402268,0.6017015176715418,0.6545298732530965,0.730886127190906,0.6562581148939964,-2.0011107137102786,-1.401624165690882,-1.1277718208361982,-1.6902473634511677,-0.9862354124304765,-0.3843835867526752,-0.8594391550479588,-0.08611846975069604,0.8581393589585085,-1.721914495038679,-1.0689598179490185,-0.3092157347739622,-0.8364101126846007,-0.5204360824511298,0.2389947535019853,-0.5252203675682054,0.30366104112661535,0.6159354284910474,-0.435872149297883,-0.6447337420043593,-0.23241168197119375,-0.5587083820758042,1.041243457257335,0.8817285003055622,-0.26701608310034963,1.3191728066043842,1.8496150463458647,3.386603227960955,2.577392932125604,2.0164687052326857,2.742386963987094,2.4759556449172653,1.5890798536880586,2.0797690499161274,1.3936996660368615,0.526266689832787,2.1494936444772117,1.3439789102692503,0.8974360954125638,1.5556876042678869,1.1133444680916704,0.7787072215871649,1.5272445935190495,0.9683117522027519,0.4508434743296963,3.148705453095126,2.1940503695982123,1.6170595825117984,1.9767515040098467,1.6783036801449804,1.3824772146737834,1.6598092042514219,1.310974231133748,1.4049921979750997,1.633755224364549,1.0629489030486772,0.9762989330542741,1.4533820060237872,0.9094976190919496,0.8464727321127448,0.9296645298141584,1.0011717812536227,0.5516417044666925,1.1266215110473177,1.6538201367889955,1.1374806460255649,0.6752233307760405,0.7673516544586589,0.5878797298215289,0.6680993674487837,0.7634037525184827,0.6744098568932007,2.748531043995524,1.8408619985658856,1.3041882579216209,1.5087537467242018,1.127296144228879,1.3174403795296104,1.1867323878207339,1.1961429873938458,1.425842767060974,0.04768812897887412,-0.8844077695541581,-0.8311648584366699,-0.6635270206565486,-0.7873155311120089,0.08889868662824807,-1.3441739029149733,-0.050017920940007315,1.233200262847812,-0.5528033162942427,-0.7129326557932142,-0.2820925617554051,-0.5532163889953494,0.21697816891814925,1.061033810417074,-0.06640879293318157,2.0138602000138315,1.9703202786758967,1.4211571403952072,0.613376271567003,0.4646748603491338,0.2112926715157992,0.9855046302698077,1.8168885366878345,1.001503531199859,1.8063307278112284,3.3313453239347925,-2.3264743436987834,4.793842035562759,-8.641858080635599,3.836800525787465,2.034508221817777,-0.024755656183946692,2.115792520622966,0.9475720542214578,-5.364895256471904,2.0053737131748597,0.31496858344002393,0.11672463799316865,0.9552892680304245,3.487270960365534,2.022957705129027,-0.29188494657779257,0.06967012536285544,0.177689795616857,0.9665815520741936,-1.9184908008554555,12.745432090378438,-5.483594167246502,0.047704634782013824,0.6997784542823663,0.3662062683804299,-8.660009433642534,-1.5280111082445091,-2.4539552383839633,5.429591069430501,0.26143441249619165,0.9175521842932546,0.48173014028291994,-2.177203686590361,-0.09722806982236633,0.9945521821911535,-4.87028883165427,26.12253918706823,-12.2710763277996,-2.8652537670975398,0.36691567605104874,-7.8600371451070705,-0.5910491774723641,2.450029469879857,0.39375208578267795,-0.708324054555089,-6.8493116886415315,-0.33024817020006175,-0.5716524813846768,0.11638463772401231,0.011864989176039842,0.10045773645126843,0.7110906165522497,-1.507019305206718,0.21317675999595487,0.0879114052101766,0.3694790134693644,0.07609352336621988,0.2499891764164648,0.0029945561784234798,3.6815634891695246,0.06125980504647721,0.2755221624994224,0.18532411056350817,0.02521575478409943";
    //evaluate(weights);
}

From source file:de.dfki.resc28.ole.bootstrap.App.java

public static void main(String[] args) throws IOException {
    configure();// ww w  .jav  a  2 s  .  c  o  m
    initRepoModel();

    File[] files = new File(fPartsDirectory).listFiles(new FilenameFilter() {
        public boolean accept(File dir, String name) {
            return name.toLowerCase().endsWith(".dat");
        }
    });

    if (files == null) {
        System.err.format("Error: %s is not a directory%n", fPartsDirectory);
        System.exit(1);
    }

    int fileCounter = 0;

    for (File file : files) {
        System.out.format("Parsing file: %s [%d/%d]...%n", file.getAbsolutePath(), fileCounter + 1,
                files.length);

        parseFile(file);

        fileCounter++;
    }

    fGraphStore.addToNamedGraph(fRepo.getURI(), fRepoModel);

    System.exit(0);
}

From source file:org.mzd.shap.spring.cli.ConfigSetup.java

public static void main(String[] args) {
    // check args
    if (args.length != 1) {
        exitOnError(1, null);/*from   www.j  a  v  a  2  s  .c o  m*/
    }

    // check file existance
    File analyzerXML = new File(args[0]);
    if (!analyzerXML.exists()) {
        exitOnError(1, "'" + analyzerXML.getPath() + "' did not exist\n");
    }

    // prompt user whether existing data should be purged
    boolean isPurged = false;
    String ormContext = null;
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    try {
        System.out.println("\nDo you wish to purge the database before running setup?");
        System.out.println("WARNING: all existing data in SHAP will be lost!");
        System.out.println("Really purge? yes/[NO]");
        String ans = br.readLine();
        if (ans.toLowerCase().equals("yes")) {
            System.out.println("Purging enabled");
            ormContext = "orm-purge-context.xml";
            isPurged = true;
        } else {
            System.out.println("Purging disabled");
            ormContext = "orm-context.xml";
        }
    } catch (IOException ex) {
        throw new RuntimeException(ex);
    }

    // run tool
    try {
        // Using a generic application context since we're referencing
        // both classpath and filesystem resources.
        GenericApplicationContext ctx = new GenericApplicationContext();
        XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(ctx);
        xmlReader.loadBeanDefinitions(new ClassPathResource("datasource-context.xml"),
                new ClassPathResource(ormContext), new FileSystemResource(analyzerXML));
        ctx.refresh();

        /*
         * Create an base admin user.
         */
        if (isPurged) {
            //only attempted if we've wiped the old database.
            RoleDao roleDao = (RoleDao) ctx.getBean("roleDao");
            Role adminRole = roleDao.saveOrUpdate(new Role("admin", "ROLE_ADMIN"));
            Role userRole = roleDao.saveOrUpdate(new Role("user", "ROLE_USER"));
            UserDao userDao = (UserDao) ctx.getBean("userDao");
            userDao.saveOrUpdate(new User("admin", "admin", "shap01", adminRole, userRole));
        }

        /*
         * Create some predefined analyzers. Users should have modified
         * the configuration file to suit their environment.
         */
        AnnotatorDao annotatorDao = (AnnotatorDao) ctx.getBean("annotatorDao");
        DetectorDao detectorDao = (DetectorDao) ctx.getBean("detectorDao");

        ConfigSetup config = (ConfigSetup) ctx.getBean("configuration");

        for (Annotator an : config.getAnnotators()) {
            System.out.println("Adding annotator: " + an.getName());
            annotatorDao.saveOrUpdate(an);
        }

        for (Detector dt : config.getDetectors()) {
            System.out.println("Adding detector: " + dt.getName());
            detectorDao.saveOrUpdate(dt);
        }

        System.exit(0);
    } catch (Throwable t) {
        System.err.println(t.getMessage());
        System.exit(1);
    }
}

From source file:com.rackspacecloud.blueflood.tools.ops.GetPoints.java

public static void main(String args[]) {
    Map<String, Object> options = parseOptions(args);

    Locator locator = Locator.createLocatorFromPathComponents((String) options.get(TENANT_ID),
            (String) options.get(METRIC));

    AstyanaxReader reader = AstyanaxReader.getInstance();

    Long from = (Long) options.get(FROM);
    Long to = (Long) options.get(TO);

    if (from == null || to == null) {
        System.out.println("Either start time or end time is null.");
        to = System.currentTimeMillis();
        from = to - DEFAULT_RANGE.toMillis();
        System.out.println("Using range: " + from + " - " + to);
    }//from   www.j  a  va  2s . c o m

    if (from >= to) {
        System.err.println("End time " + to + " has to be greater than start time " + from);
        System.exit(2);
    }

    Granularity gran = Granularity.FULL;
    String res = (String) options.get("resolution");
    try {
        gran = Granularity.fromString(res.toLowerCase());
    } catch (Exception ex) {
        System.out.println("Exception mapping resolution to Granularity. Using FULL resolution instead.");
        gran = Granularity.FULL;
    } finally {
        if (gran == null) {
            gran = Granularity.FULL;
        }
    }

    System.out.println(
            "Locator: " + locator + ", from: " + from + ", to: " + to + ", resolution: " + gran.shortName());

    MetricData data = reader.getDatapointsForRange(locator, new Range(from, to), gran);
    Map<Long, Points.Point> points = data.getData().getPoints();
    for (Map.Entry<Long, Points.Point> item : points.entrySet()) {
        String output = String.format("Timestamp: %d, Data: %s, Unit: %s", item.getKey(),
                item.getValue().getData().toString(), data.getUnit());
        System.out.println(output);
    }
}

From source file:MainClass.java

public static void main(String[] a) {
    Display d = new Display();
    Shell s = new Shell(d);

    s.setSize(250, 200);// w  ww .  j a v a 2 s. c  o  m
    s.setText("A KeyListener Example");
    s.setLayout(new RowLayout());

    final Combo c = new Combo(s, SWT.DROP_DOWN | SWT.BORDER);
    c.add("A");
    c.add("B");
    c.add("C");
    c.add("D");

    c.addKeyListener(new KeyListener() {
        String selectedItem = "";

        public void keyPressed(KeyEvent e) {
            if (c.getText().length() > 0) {
                return;
            }
            String key = Character.toString(e.character);
            String[] items = c.getItems();
            for (int i = 0; i < items.length; i++) {
                if (items[i].toLowerCase().startsWith(key.toLowerCase())) {
                    c.select(i);
                    selectedItem = items[i];
                    return;
                }
            }
        }

        public void keyReleased(KeyEvent e) {
            if (selectedItem.length() > 0)
                c.setText(selectedItem);
            selectedItem = "";
        }
    });
    s.open();
    while (!s.isDisposed()) {
        if (!d.readAndDispatch())
            d.sleep();
    }
    d.dispose();

}

From source file:com.mycompany.test.Jaroop.java

/**
 * This is the main program which will receive the request, calls required methods
 * and processes the response.//ww  w  . j  a va  2  s.  c o  m
 * @param args
 * @throws IOException
 */
public static void main(String[] args) throws IOException {
    Scanner scannedInput = new Scanner(System.in);
    String in = "";
    if (args.length == 0) {
        System.out.println("Enter the query");
        in = scannedInput.nextLine();
    } else {
        in = args[0];
    }
    in = in.toLowerCase().replaceAll("\\s+", "_");
    int httpStatus = checkInvalidInput(in);
    if (httpStatus == 0) {
        System.out.print("Not found");
        System.exit(0);
    }
    String url = "https://en.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&exintro=&explaintext=&titles="
            + in;
    HttpURLConnection connection = getConnection(url);
    BufferedReader input = new BufferedReader(new InputStreamReader(connection.getInputStream()));
    String request = "";
    StringBuilder response = new StringBuilder();
    while ((request = input.readLine()) != null) {
        //only appending what ever is required for JSON parsing and ignoring the rest
        response.append("{");
        //appending the key "extract" to the string so that the JSON parser can parse it's value,
        //also we don't need last 3 paranthesis in the response, excluding them as well.
        response.append(request.substring(request.indexOf("\"extract"), request.length() - 3));
    }
    parseJSON(response.toString());
}

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:com.handany.base.generator.Generator.java

public static void main(String[] args) throws IOException {
    String directoryPath = "src/main/java";

    String modelDirectory = directoryPath + File.separator
            + StringUtils.replace(MODEL_PACKAGE, ".", File.separator) + File.separator;
    String daoDirectory = directoryPath + File.separator + StringUtils.replace(DAO_PACKAGE, ".", File.separator)
            + File.separator;//from  w  ww. j ava 2  s  .  c  o  m
    String serviceDirectory = directoryPath + File.separator
            + StringUtils.replace(SERVICE_PACKAGE, ".", File.separator) + File.separator;
    String serviceImplDirectory = directoryPath + File.separator
            + StringUtils.replace(SERVICE_IMPL_PACKAGE, ".", File.separator) + File.separator;
    String controllerDirectory = directoryPath + File.separator
            + StringUtils.replace(CONTROLLER_PACKAGE, ".", File.separator) + File.separator;
    File fileDirectory = new File(directoryPath);
    if (!fileDirectory.isDirectory()) {
        FileUtils.forceMkdir(fileDirectory);
    }

    List<TableBean> tableBeanList = getTables();

    ArrayList<String> nameList = new ArrayList<>();

    //      nameList.add("bm_classroom_course");
    nameList.add("bm_sales_promotion");

    for (TableBean tableBean : tableBeanList) {
        System.out.println("table:" + tableBean.getTableName());
        String tableName = tableBean.getTableName();

        if (!nameList.contains(tableName.toLowerCase())) {
            continue;
        }

        Map<String, Object> varMap = new HashMap<>();
        varMap.put("tableBean", tableBean);
        varMap.put("schemaName", SCHEMA_NAME);
        varMap.put("modelPackage", MODEL_PACKAGE);
        varMap.put("daoPackage", DAO_PACKAGE);
        varMap.put("servicePackage", SERVICE_PACKAGE);
        varMap.put("serviceImplPackage", SERVICE_IMPL_PACKAGE);
        varMap.put("controllerPackage", CONTROLLER_PACKAGE);

        Template modelTemplate = FreemarkerUtil.getTemplate("model.ftl");
        FreemarkerUtil.outputProcessResult(modelDirectory + tableBean.getTableNameCapitalized() + ".java",
                modelTemplate, varMap);

        //            Template daoTemplate = FreemarkerUtil.getTemplate("dao.ftl");
        //            FreemarkerUtil.outputProcessResult(daoDirectory + tableBean.getTableNameCapitalized() + "Mapper.java", daoTemplate, varMap);

        Template mapperTemplate = FreemarkerUtil.getTemplate("mapper.ftl");
        FreemarkerUtil.outputProcessResult(daoDirectory + tableBean.getTableNameCapitalized() + "Mapper.xml",
                mapperTemplate, varMap);

        //            Template serviceTemplate = FreemarkerUtil.getTemplate("service.ftl");
        //            FreemarkerUtil.outputProcessResult(serviceDirectory + tableBean.getTableNameCapitalized() + "Service.java", serviceTemplate, varMap);
        //
        //            Template serviceImplTemplate = FreemarkerUtil.getTemplate("serviceimpl.ftl");
        //            FreemarkerUtil.outputProcessResult(serviceImplDirectory + tableBean.getTableNameCapitalized() + "ServiceImpl.java", serviceImplTemplate, varMap);
        //
        //            Template controllerTemplate = FreemarkerUtil.getTemplate("controller.ftl");
        //            FreemarkerUtil.outputProcessResult(controllerDirectory + tableBean.getTableNameCapitalized() + "Controller.java", controllerTemplate, varMap);
    }
}