Example usage for java.util StringTokenizer nextToken

List of usage examples for java.util StringTokenizer nextToken

Introduction

In this page you can find the example usage for java.util StringTokenizer nextToken.

Prototype

public String nextToken() 

Source Link

Document

Returns the next token from this string tokenizer.

Usage

From source file:Main.java

public static String getAtLeastOne(StringTokenizer stringT) {
    StringBuilder text = new StringBuilder(stringT.nextToken());
    while (stringT.hasMoreTokens()) {
        text.append(' ');
        text.append(stringT.nextToken());
    }/*w  w  w  . j  a  v  a2s.  c o m*/
    return text.toString();
}

From source file:Main.java

public static String getEventOfExpression(String expression) {
    // pattern for events
    Pattern eventPattern = Pattern.compile("^[\\w\\W&&[^/\\[\\]]]+(\\[[\\w\\W&&[^\\[\\]]]+\\])?(/[\\w\\W]+)?$");
    Matcher eventMatcher = eventPattern.matcher(expression);
    if (eventMatcher.find() && (eventMatcher.group().length() == expression.length())) {
        StringTokenizer st = new StringTokenizer(expression, "[]/");
        return st.nextToken();
    }/*from www .jav a2s.c  o m*/
    return null;
}

From source file:WordCount.java

static void processLine(String line, Map map) {
    StringTokenizer st = new StringTokenizer(line);
    while (st.hasMoreTokens()) {
        addWord(map, st.nextToken());
    }/*  w w w.  j a  v a 2 s.  c om*/
}

From source file:Main.java

public static int findProcessIdWithPS(String command) throws Exception {
    int procId = -1;
    Runtime r = Runtime.getRuntime();
    Process procPs = null;/*  w  w w .  jav  a  2 s  . co  m*/
    procPs = r.exec(SHELL_CMD_PS);

    BufferedReader reader = new BufferedReader(new InputStreamReader(procPs.getInputStream()));
    String line = null;

    while ((line = reader.readLine()) != null) {
        if (line.indexOf(' ' + command) != -1) {
            StringTokenizer st = new StringTokenizer(line, " ");
            st.nextToken(); // proc owner
            procId = Integer.parseInt(st.nextToken().trim());
            break;
        }
    }

    return procId;
}

From source file:Main.java

public static String getConditionOfExpression(String expression) {
    // pattern for conditions
    Pattern conditionPattern = Pattern
            .compile("^([\\w\\W&&[^/\\[\\]]]+)?(\\[[\\w\\W&&[^\\[\\]]]+\\])(/[\\w\\W]+)?$");
    Matcher conditionMatcher = conditionPattern.matcher(expression);
    if (conditionMatcher.find() && (conditionMatcher.group().length() == expression.length())) {
        StringTokenizer st = new StringTokenizer(expression, "]");
        String condition = st.nextToken();
        condition = condition.substring(condition.indexOf("[") + 1);
        return condition;
    }/*from w  ww . j  a  v a 2  s.  c  o m*/
    return null;
}

From source file:cc.recommenders.utils.parser.MavenVersionParser.java

private static String parseString(final StringTokenizer st) {
    return st.nextToken();
}

From source file:Main.java

public static String GetFileName(String file) {

    StringTokenizer st = new StringTokenizer(file, "/");
    while (st.hasMoreTokens()) {
        file = st.nextToken();
    }/*  www  . j ava  2s  .c  om*/
    return file;
}

From source file:cc.recommenders.utils.parser.MavenVersionParser.java

private static int parseInt(final StringTokenizer st) {
    return Integer.parseInt(st.nextToken());
}

From source file:Main.java

/**
 * suppose the component path is "a.b.c", get 'a' as object name.
 * //from w w  w  . ja  v a  2s.  co m
 * @param componentPath
 * @return
 */
public static String getObjectNameOfComponentPath(String componentPath) {
    String objectName = componentPath;
    StringTokenizer tokens = new StringTokenizer(componentPath, ".");
    objectName = tokens.hasMoreTokens() ? tokens.nextToken() : objectName;
    return objectName;
}

From source file:Main.java

public static String tag(String inElement, String inString) {
    StringTokenizer wkTok = new StringTokenizer(inElement, " ");
    String wkElementOnly = inElement;
    wkElementOnly = wkTok.nextToken();
    return tag(inElement) + inString + etag(wkElementOnly);
}