Example usage for java.lang String contains

List of usage examples for java.lang String contains

Introduction

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

Prototype

public boolean contains(CharSequence s) 

Source Link

Document

Returns true if and only if this string contains the specified sequence of char values.

Usage

From source file:Main.java

public static void main(String[] args) {

    PropertyPermission permission = new PropertyPermission("java.home.*", "read,write");

    if ("java.home.usr".matches(permission.getName())) {
        String actions = permission.getActions();

        if (actions.contains("read")) {
            System.out.println("Has permissions on java.home.usr for read");
        }/*from   w w  w.j  a v  a 2  s  .c  om*/

        if (actions.contains("write")) {
            System.out.println("Has permissions on java.home.usr for write");
        }
    }
}

From source file:Main.java

public static void main(String[] argv) {
    String str = "Java2s.com";
    String str2 = "2s.com";
    System.out.println(str.contains(str2));

}

From source file:com.cloudera.sparkstreaming.StreamingLogInput.java

public static void main(String[] args) throws Exception {
    String master = args[0];/*from  w w  w. jav  a  2 s .c  om*/
    JavaSparkContext sc = new JavaSparkContext(master, "StreamingLogInput");
    // Create a StreamingContext with a 1 second batch size
    JavaStreamingContext jssc = new JavaStreamingContext(sc, new Duration(1000));
    // Create a DStream from all the input on port 7777
    JavaDStream<String> lines = jssc.socketTextStream("localhost", 7777);
    // Filter our DStream for lines with "error"
    JavaDStream<String> errorLines = lines.filter(new Function<String, Boolean>() {
        public Boolean call(String line) {
            return line.contains("error");
        }
    });
    // Print out the lines with errors, which causes this DStream to be evaluated
    errorLines.print();
    // start our streaming context and wait for it to "finish"
    jssc.start();
    // Wait for 10 seconds then exit. To run forever call without a timeout
    jssc.awaitTermination(10000);
    // Stop the streaming context
    jssc.stop();
}

From source file:gov.loc.repository.bagger.BaggerApplication.java

public static void main(String[] args) {
    String rootContextDirectoryClassPath = "/gov/loc/repository/bagger/ctx";

    String startupContextPath = rootContextDirectoryClassPath + "/common/richclient-startup-context.xml";

    String richclientApplicationContextPath = rootContextDirectoryClassPath
            + "/common/richclient-application-context.xml";

    String businessLayerContextPath = rootContextDirectoryClassPath + "/common/business-layer-context.xml";

    try {/*w ww  .  j av  a 2s.c o  m*/
        new ApplicationLauncher(startupContextPath,
                new String[] { richclientApplicationContextPath, businessLayerContextPath });
    } catch (IllegalStateException ex1) {
        LogFactory.getLog(BaggerApplication.class).error("IllegalStateException during startup", ex1);
        JOptionPane.showMessageDialog(new JFrame(), "An illegal state error occured.\n",
                "Bagger startup error!", JOptionPane.ERROR_MESSAGE);
        System.exit(1);
    } catch (PropertyAccessException ex) {
        LogFactory.getLog(BaggerApplication.class).error("PropertyAccessException during startup", ex);
        JOptionPane.showMessageDialog(new JFrame(), "An error occured loading properties.\n",
                "Bagger startup error!", JOptionPane.ERROR_MESSAGE);
        System.exit(1);
    } catch (RuntimeException e) {
        LogFactory.getLog(BaggerApplication.class).error("RuntimeException during startup", e);
        String msg = e.getMessage();
        if (msg.contains("SAXParseException")) {
            JOptionPane.showMessageDialog(new JFrame(),
                    "An error occured parsing application context.  You may have no internet access.\n",
                    "Bagger startup error!", JOptionPane.ERROR_MESSAGE);
        } else {
            JOptionPane.showMessageDialog(new JFrame(), "An error occured during startup.\n",
                    "Bagger startup error!", JOptionPane.ERROR_MESSAGE);
        }
        System.exit(1);
    }
}

From source file:com.music.tools.HeaderManager.java

public static void main(String[] args) throws Exception {
    String path = args[0];//from www  .  j ava  2s .c o  m
    String header = FileUtils.readFileToString(new File(path, "src/main/resources/license/AGPL-3-header.txt"),
            Charsets.UTF_8);

    File sourceRoot = new File(path, "src");
    System.out.println("Source root is: " + sourceRoot);
    Collection<File> files = FileUtils.listFiles(sourceRoot, new String[] { "java" }, true);
    System.out.println("Ammending " + files.size() + " source files");
    for (File file : files) {
        System.out.println("Checking file " + file);
        String content = FileUtils.readFileToString(file, Charsets.UTF_8);
        if (content.contains("Copyright")) {
            System.out.println("Skipping file " + file);
            continue;
        }
        content = header + LS + LS + content;
        FileUtils.write(file, content);
    }
}

From source file:com.xue777hua.emails.test.Test.java

public static void main(String[] args) {
    String text = "<div id=\"frag_1\" class=\"page_fragment auth_frag\" data-first=\"true\" data-fid=\"1\"><div class=\"module_topic_paths\"></div><h1 class=\"svTitle\" id=\"tm005\">Effect of inulin and pectin on rheological and thermal properties of potato starch paste and gel</h1><ul class=\"authorGroup noCollab\"><li><a href=\"#\" class=\"authorName\" id=\"authname_N41d730a0N3ee493d4\" data-t=\"a\" data-fn=\"Teresa\" data-ln=\"Witczak\" data-pos=\"1\" data-tb=\"\">Teresa Witczak</a><a title=\"Affiliation: a\" href=\"#af005\" class=\"intra_ref auth_aff\" id=\"baf005\"><sup>a</sup></a><sup>, </sup><a title=\"Corresponding author contact information\" href=\"#cor1\" id=\"bcor1\" class=\"intra_ref auth_corr\"><img class=\"imgLazyJSB\" alt=\"Corresponding author contact information\" src=\"/sd/grey_pxl.gif\" data-inlimg=\"/entities/REcor.gif\"><noscript><img alt=\"Corresponding author contact information\" src=\"http://origin-cdn.els-cdn.com/sd/entities/REcor.gif\"></noscript></a><sup>, </sup><a href=\"mailto:t.witczak@ur.krakow.pl\" class=\"auth_mail\"><img class=\"imgLazyJSB\" src=\"/sd/grey_pxl.gif\" alt=\"E-mail the corresponding author\" data-inlimg=\"/entities/REemail.gif\"><noscript><img src=\"http://origin-cdn.els-cdn.com/sd/entities/REemail.gif\" alt=\"E-mail the corresponding author\"></noscript></a>, </li><li><a href=\"#\" class=\"authorName\" id=\"authname_N41d730a0N3ee4953c\" data-t=\"a\" data-fn=\"Mariusz\" data-ln=\"Witczak\" data-pos=\"2\" data-tb=\"\">Mariusz Witczak</a><a title=\"Affiliation: a\" href=\"#af005\" class=\"intra_ref auth_aff\" id=\"baf005\"><sup>a</sup></a>, </li><li><a href=\"#\" class=\"authorName\" id=\"authname_N41d730a0N3ee495f0\" data-t=\"a\" data-fn=\"Rafa&#322;\" data-ln=\"Ziobro\" data-pos=\"3\" data-tb=\"\">Rafa Ziobro</a><a title=\"Affiliation: b\" href=\"#af010\" class=\"intra_ref auth_aff\" id=\"baf010\"><sup>b</sup></a></li></ul><!--VALIDHTML--><ul class=\"affiliation\"><li id=\"af005\"><sup>a</sup> <span id=\"\">Department of Engineering and Machinery for Food Industry, University of Agriculture in Krakow, Balicka 122 Str., 30-149 Krakow, Poland</span></li><li id=\"af010\"><sup>b</sup> <span id=\"\">Department of Carbohydrates Technology, University of Agriculture in Krakow, Balicka 122 Str., 30-149 Krakow, Poland</span></li></ul><!--VALIDHTML--><!--VALIDHTML--><dl class=\"articleDates\"><dd>Received 24 May 2013, Revised 1 October 2013, Accepted 1 October 2013, Available online 11 October 2013</dd></dl><!--VALIDHTML--><div class=\"moreInformation\"></div><div id=\"ppvPlaceHolder\" class=\"hidden\"></div><!--VALIDHTML--><div id=\"showMoreButtons\"></div><dl class=\"extLinks\"><dd class=\"doiLink\"></dd><dd class=\"rightsLink\"></dd></dl><div class=\"articleOAlabelForced\"></div><div id=\"refersToAndreferredToBy\"><dl id=\"referredToBy\" class=\"documentThread\"><!--Referred To By--></dl></div><!--FRAGMENTEND--><div class=\"page_fragment_ind auth_frag\" data-id=\"frag_2\"></div></div>";
    String authorList = "";
    String articleTitle = "";
    // ???title//from   ww  w .ja  v a  2  s. c o m
    Pattern articleTitlePattern = Pattern.compile("<h1.+?svTitle.+?>(.+?)</h1>");
    Matcher articleTitleMatcher = articleTitlePattern.matcher(text);
    while (articleTitleMatcher.find()) {
        articleTitle = articleTitleMatcher.group(1);
        articleTitle = StringEscapeUtils.unescapeHtml(articleTitle);
        articleTitle = StringUtils.stripTags(articleTitle);
        System.out.println("" + articleTitle);
    }
    // ???
    Pattern p = Pattern.compile("<ul.+?authorGroup.+?>(.+?)</ul>");
    Matcher m = p.matcher(text);
    while (m.find()) {
        authorList = m.group(1);
    }
    p = Pattern.compile("<li>(.+?)</li>");
    m = p.matcher(authorList);
    while (m.find()) {
        String authorItem = m.group(1);
        if (authorItem.contains("mailto")) {
            Pattern nameEmailPattern = Pattern
                    .compile("data-tb=\"[\\d]{0,}\">(.+?)</a>.*href=\"mailto:(.+?)\" class=\"auth_mail\">");
            Matcher nameEmailMatcher = nameEmailPattern.matcher(authorItem);
            if (nameEmailMatcher.find()) {
                String name = nameEmailMatcher.group(1);
                String email = nameEmailMatcher.group(2);
                name = StringEscapeUtils.unescapeHtml(name);
                // ???new ArrayList
                List<String> fieldList = new ArrayList<String>();
                fieldList.add(name);
                fieldList.add(email);
                fieldList.add(articleTitle);
                int hashKey = (name + email + articleTitle).hashCode();
                System.out.println("?????TitlehashKey:" + name + "|" + email
                        + "|" + articleTitle + "|" + hashKey + ",  nameEmailsList");

            }
        }
    }

}

From source file:cool.pandora.modeller.ModellerApplication.java

public static void main(final String[] args) {
    final String rootContextDirectoryClassPath = "cool/pandora/modeller/ctx";

    final String startupContextPath = rootContextDirectoryClassPath + "/common/richclient-startup-context.xml";

    final String richclientApplicationContextPath = rootContextDirectoryClassPath
            + "/common/richclient-application-context.xml";

    final String businessLayerContextPath = rootContextDirectoryClassPath
            + "/common/business-layer-context.xml";

    try {//from   w ww  .  j a v a  2s.  c  o  m
        new ApplicationLauncher(startupContextPath,
                new String[] { richclientApplicationContextPath, businessLayerContextPath });
    } catch (final IllegalStateException ex1) {
        log.error("IllegalStateException during startup", ex1);
        JOptionPane.showMessageDialog(new JFrame(), "An illegal state error occured.\n",
                "Bagger startup error!", JOptionPane.ERROR_MESSAGE);
        System.exit(1);
    } catch (final PropertyAccessException ex) {
        log.error("PropertyAccessException during startup", ex);
        JOptionPane.showMessageDialog(new JFrame(), "An error occured loading properties.\n",
                "Bagger startup " + "error!", JOptionPane.ERROR_MESSAGE);
        System.exit(1);
    } catch (final RuntimeException e) {
        log.error("RuntimeException during startup", e);
        final String msg = e.getMessage();
        if (msg.contains("SAXParseException")) {
            JOptionPane.showMessageDialog(new JFrame(),
                    "An error occured parsing application context.  You may " + "have no "
                            + "internet access.\n",
                    "Bagger startup error!", JOptionPane.ERROR_MESSAGE);
        } else {
            JOptionPane.showMessageDialog(new JFrame(), "An error occured during startup.\n",
                    "Bagger startup " + "error!", JOptionPane.ERROR_MESSAGE);
        }
        System.exit(1);
    }
}

From source file:com.cisco.tbd.stec.client.Runner.java

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

    //if (args.length == 0) {
    //   System.err.println("Specify log file location");
    //}/*  w  w  w . jav a 2 s . c om*/

    RuleRequester.runWithFrequency(30000);

    String filePath = "/var/log/snort/mylog.txt";

    //        
    //        List<String> lines = getLinesOfFile(filePath);
    //       
    //        for (String line : lines) {
    //            ServerConnection.pushDetectedThreat(LogUtils.getAttackData(line));
    //        }

    while (true) {
        int currentLineCount = FileUtils.getFileLineCount(filePath);

        if (currentLineCount != lastLineCount) {
            String lastLine = FileUtils.getLastLineOfFile(filePath);
            if (lastLine.contains("/n")) {
                LogEntry logEntry = LogUtils.getAttackData(lastLine);
                System.out.println(logEntry.toString());
                if (logEntry instanceof AttackLogEntry) {
                    ServerConnection.pushDetectedThreat((AttackLogEntry) logEntry);
                    System.out.println(logEntry.toString());
                }

                lastLineCount = currentLineCount;
            }
        }

    }
    //System.err.println("Specify output folder in mtukuacs/output");
}

From source file:com.senseidb.search.node.inmemory.InMemoryIndexPerfEval.java

public static void main(String[] args) throws Exception {
    final InMemorySenseiService memorySenseiService = InMemorySenseiService.valueOf(
            new File(InMemoryIndexPerfEval.class.getClassLoader().getResource("test-conf/node1/").toURI()));

    final List<JSONObject> docs = new ArrayList<JSONObject>(15000);
    LineIterator lineIterator = FileUtils.lineIterator(
            new File(InMemoryIndexPerfEval.class.getClassLoader().getResource("data/test_data.json").toURI()));
    int i = 0;//from  ww  w  .j  a v  a2 s.  c o  m
    while (lineIterator.hasNext() && i < 100) {
        String car = lineIterator.next();
        if (car != null && car.contains("{"))
            docs.add(new JSONObject(car));
        i++;
    }
    Thread[] threads = new Thread[10];
    for (int k = 0; k < threads.length; k++) {
        threads[k] = new Thread(new Runnable() {
            public void run() {
                long time = System.currentTimeMillis();
                //System.out.println("Start thread");
                for (int j = 0; j < 1000; j++) {
                    //System.out.println("Send request");
                    memorySenseiService.doQuery(getRequest(), docs);
                }
                System.out.println("time = " + (System.currentTimeMillis() - time));
            }
        });
        threads[k].start();
    }
    Thread.sleep(500000);
}

From source file:com.ms.commons.file.excel.ExcelParser.java

public static void main(String args[]) {
    HSSFWorkbook workBook = null;/*from  ww w.ja  v  a2 s . c om*/
    File file = new File("/home/zxc/back_word/dump_word/33_2013_07_07.xls");
    InputStream excelDocumentStream = null;
    try {
        excelDocumentStream = new FileInputStream(file);
        POIFSFileSystem fsPOI = new POIFSFileSystem(new BufferedInputStream(excelDocumentStream));
        workBook = new HSSFWorkbook(fsPOI);
        ExcelParser parser = new ExcelParser(workBook.getSheetAt(0));
        String[] res;
        while ((res = parser.splitLine()) != null) {
            if (res.length == 7) {
                String resStr = StringUtils.join(res);
                if (resStr.contains("?")) {
                    continue;
                }
            }
            for (int i = 0; i < res.length; i++) {
                System.out.println("Token Found [" + res[i] + "]");
            }
        }
        excelDocumentStream.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
}