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:edu.ncsa.uiuc.rdfrepo.testing.USeekMSailFac.java

private static Collection<StatementPattern> createPatternFromString(String patternString, Sail sail) {
    Collection<StatementPattern> patterns = new ArrayList<StatementPattern>();
    //        StringTokenizer tokenizer = new StringTokenizer(patternString, ".");
    Collection<String> statStrings = tokenizePatternString(patternString);
    for (String statString : statStrings) {
        //            String statString = tokenizer.nextToken();
        StringTokenizer tokenizer2 = new StringTokenizer(statString, " ");
        StatementPattern pattern = new StatementPattern();

        pattern.setSubjectVar(createVar(tokenizer2.nextToken(), sail));
        pattern.setPredicateVar(createVar(tokenizer2.nextToken(), sail));
        pattern.setObjectVar(createVar(tokenizer2.nextToken(), sail));

        patterns.add(pattern);//from   w  ww. ja va  2s  .  com
    }
    return patterns;

}

From source file:SplitPaneDemo2.java

protected static Vector parseList(String theStringList) {
    Vector v = new Vector(10);
    StringTokenizer tokenizer = new StringTokenizer(theStringList, " ");
    while (tokenizer.hasMoreTokens()) {
        String image = tokenizer.nextToken();
        v.addElement(image);/*from www. j  av a2  s .  c  o m*/
    }
    return v;
}

From source file:com.apporiented.hermesftp.utils.IOUtils.java

/**
 * Tries to figure out the application's home directory.
 * //  ww  w.j  av a2  s .c  om
 * @return The directory.
 */
public static File getHomeDir() {
    File result = null;
    String cp = System.getProperty("java.class.path");
    StringTokenizer tokenizer = new StringTokenizer(cp, File.pathSeparator);
    if (tokenizer.countTokens() == 1) {
        File jar = new File(tokenizer.nextToken());
        try {
            result = jar.getCanonicalFile().getParentFile().getParentFile();
        } catch (IOException e) {
        }
    } else {
        File userDir = new File(System.getProperty("user.dir"));
        result = userDir.getAbsoluteFile().getParentFile();
    }
    return result;
}

From source file:cz.incad.cdk.RepairVCProcess.java

@Process
public static void process() {
    try {//from w w w .ja v a2  s.co  m
        FedoraAccessImpl fa = new FedoraAccessImpl(KConfiguration.getInstance(), null);
        String query = "*%20<fedora-model:hasModel>%20*";
        String ri = KConfiguration.getInstance().getProperty("FedoraResourceIndex");
        String fuser = KConfiguration.getInstance().getProperty("fedoraUser");
        String fpass = KConfiguration.getInstance().getProperty("fedoraPass");

        LOGGER.info("requesting resource index");
        InputStream istream = RESTHelper.inputStream(
                ri + "?type=triples&lang=spo&format=N-Triples&distinct=on&query=" + query, fuser, fpass);
        LOGGER.info("processing results");

        BufferedReader bReader = new BufferedReader(new InputStreamReader(istream));
        String line = null;
        while ((line = bReader.readLine()) != null) {
            StringTokenizer tokenizer = new StringTokenizer(line, " ,\t");
            if (tokenizer.hasMoreTokens()) {
                String nextToken = tokenizer.nextToken();
                nextToken = nextToken.trim().substring(1);
                nextToken = nextToken.substring(0, nextToken.lastIndexOf('>'));
                try {
                    PIDParser parser = new PIDParser(nextToken);
                    parser.disseminationURI();
                    String pid = parser.getObjectPid();
                    if (pid.startsWith("uuid")) {
                        LOGGER.info("processing '" + pid + "'");
                        Document relsExt = fa.getRelsExt(pid);
                        checkRelsExt(pid, relsExt, fa);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    System.err.println("skipping " + nextToken);
                }
            }
        }
    } catch (Exception e) {
        LOGGER.log(Level.SEVERE, e.getMessage(), e);
    }
}

From source file:Main.java

public static int[] getIntArray(Context ctx, String prefsKey, String key) {
    StringTokenizer st = new StringTokenizer(
            (TextUtils.isEmpty(prefsKey) ? getPrefManager(ctx) : getPrefs(ctx, prefsKey)).getString(key, ""),
            ",");
    int[] savedList = new int[st.countTokens()];
    for (int i = 0; i < savedList.length; i++) {
        savedList[i] = Integer.parseInt(st.nextToken());
    }/*from  ww  w.j  a v a2  s  .c om*/
    return savedList;
}

From source file:net.naijatek.myalumni.util.utilities.MailUtil.java

/**
 * This method trim the email variable, so if it contains only spaces, then
 * it will be empty string, then we have 0 token :-) The returned value is
 * never null//  w ww  .  j  a  va2  s  . c o m
 *
* @param email String
* @throws BadInputException
* @return String[]
 */
private static String[] getEmails(String email) throws BadInputException {
    if (email == null) {
        email = "";
    }
    email = email.trim();// very important
    StringTokenizer t = new StringTokenizer(email, ";");
    String[] ret = new String[t.countTokens()];
    int index = 0;
    while (t.hasMoreTokens()) {
        String mail = t.nextToken().trim();
        checkGoodEmail(mail);
        ret[index] = mail;
        //log.debug(ret[index]);
        index++;
    }
    return ret;
}

From source file:com.thruzero.common.core.utils.StringUtilsExt.java

/**
 * Converts the given token stream of keyValuePairs, using the given separator, into a StringMap. Leading and trailing spaces of the keys and values are
 * trimmed.//from   w  ww  .j  ava  2 s.c  o  m
 * <p>
 * Example input: "booleanTrue=true ,booleanFalse=false, integerOne=1,longOne=1234567890"
 */
public static StringMap tokensToMap(final String keyValuePairs, final String separator) {
    StringMap result = new StringMap();

    if (StringUtils.isNotEmpty(keyValuePairs)) {
        StringTokenizer st = new StringTokenizer(keyValuePairs, separator);

        while (st.hasMoreTokens()) {
            String token = st.nextToken();
            StringTokenizer st2 = new StringTokenizer(token, "=");

            result.put(StringUtils.trimToEmpty(st2.nextToken()),
                    st2.hasMoreTokens() ? StringUtils.trimToNull(st2.nextToken()) : null);
        }
    }

    return result;
}

From source file:PackageUtils.java

private static List<String> tokenize(String str, String sep) {
    StringTokenizer tokens = new StringTokenizer(str, sep);
    List<String> r = new ArrayList<String>();

    while (tokens.hasMoreTokens()) {
        r.add(tokens.nextToken());
    }/* ww w .  j  ava 2s. co m*/
    return r;
}

From source file:kr.co.exsoft.eframework.util.LicenseUtil.java

private static byte[] getBytes(String str) {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    StringTokenizer st = new StringTokenizer(str, "-", false);

    while (st.hasMoreTokens()) {
        int i = Integer.parseInt(st.nextToken());
        bos.write((byte) i);
    }/*from  w  w w .  j a  v a 2s .com*/

    return bos.toByteArray();
}

From source file:net.servicefixture.PluginManager.java

private static List<String[]> parsePluginValue(String value, int numOfTokens) {
    List<String[]> list = new ArrayList<String[]>();
    StringTokenizer pluginTokenizer = new StringTokenizer(value, PLUGIN_DELIMITER);
    while (pluginTokenizer.hasMoreTokens()) {
        String token = pluginTokenizer.nextToken();
        StringTokenizer tokenizer = new StringTokenizer(token, TOKEN_DELIMITER);
        String[] tokens = new String[tokenizer.countTokens()];
        if (tokens.length != numOfTokens) {
            throw new ServiceFixtureException("Invalid plugin value: " + value);
        }//from w  w  w  .  j a v  a  2  s.c om
        for (int i = 0; i < tokens.length; i++) {
            tokens[i] = tokenizer.nextToken().trim();
        }
        list.add(tokens);
    }
    return list;
}