Tabnine Logo
StringTokenizer
Code IndexAdd Tabnine to your IDE (free)

How to use
StringTokenizer
in
java.util

Best Java code snippets using java.util.StringTokenizer (Showing top 20 results out of 43,002)

Refine searchRefine arrow

  • BufferedReader
  • InputStreamReader
  • FileReader
  • FileInputStream
origin: hibernate/hibernate-orm

public static String[] split(String separators, String list, boolean include) {
  StringTokenizer tokens = new StringTokenizer( list, separators, include );
  String[] result = new String[tokens.countTokens()];
  int i = 0;
  while ( tokens.hasMoreTokens() ) {
    result[i++] = tokens.nextToken();
  }
  return result;
}
origin: stanfordnlp/CoreNLP

/** Basic string tokenization, skipping over white spaces */
public static ArrayList<String> tokenize(String line) {
 ArrayList<String> tokens = new ArrayList<>();
 StringTokenizer tokenizer = new StringTokenizer(line);
 while (tokenizer.hasMoreElements()) {
  tokens.add(tokenizer.nextToken());
 }
 return tokens;
}
origin: stackoverflow.com

 StringTokenizer tokens = new StringTokenizer(CurrentString, ":");
String first = tokens.nextToken();// this will contain "Fruit"
String second = tokens.nextToken();// this will contain " they taste good"
// in the case above I assumed the string has always that syntax (foo: bar)
// but you may want to check if there are tokens or not using the hasMoreTokens method
origin: org.testng/testng

public void setListeners(String listeners) {
 StringTokenizer st= new StringTokenizer(listeners, " ,");
 while(st.hasMoreTokens()) {
  m_listeners.add(st.nextToken());
 }
}
origin: cmusphinx/sphinx4

  protected void loadMapping(InputStream inputStream) throws IOException {
    InputStreamReader isr = new InputStreamReader(inputStream);
    BufferedReader br = new BufferedReader(isr);
    String line;
    while ((line = br.readLine()) != null) {
      StringTokenizer st = new StringTokenizer(line);
      if (st.countTokens() != 2) {
        throw new IOException("Wrong file format");
      }
      mapping.put(st.nextToken(), st.nextToken());
    }
    br.close();
    isr.close();
    inputStream.close();
  }
}
origin: smuyyh/BookReader

BufferedReader hin = new BufferedReader(new InputStreamReader(
    new ByteArrayInputStream(buf, 0, rlen)));
Map<String, String> pre = new HashMap<String, String>();
InputStream bin = new FileInputStream(f.getFD());
BufferedReader in = new BufferedReader(new InputStreamReader(
    bin));
    st = new StringTokenizer(contentTypeHeader, ",; ");
    if (st.hasMoreTokens()) {
      contentType = st.nextToken();
    if (!st.hasMoreTokens()) {
      Response.error(
          outputStream,
    int read = in.read(pbuf);
    while (read >= 0 && !postLine.endsWith("\r\n")) {
      postLine += String.valueOf(pbuf, 0, read);
origin: geotools/geotools

cellhead = new BufferedReader(new FileReader(cellhd));
cellhead.mark(128);
if ((line = cellhead.readLine()) == null) {
  throw new IOException(
      "The cellhead file seems to be corrupted: " + cellhd.getAbsolutePath());
            + cellhd.getAbsolutePath());
  cellhead = new BufferedReader(new FileReader(cellhd));
} else {
              new FileReader(readerGrassEnv.getCELLMISC_FORMAT()));
      while ((line = cellmiscformat.readLine()) != null) {
        StringTokenizer tokk = new StringTokenizer(line, ":");
        if (tokk.countTokens() == 2) {
          String key = tokk.nextToken().trim();
          String value = tokk.nextToken().trim();
          readerFileHeaderMap.put(key, value);
origin: spring-projects/spring-framework

@Override
@Nullable
public String[] getParameterNames(Method method) {
  if (method.getParameterCount() == 0) {
    return new String[0];
  }
  AspectJAnnotation<?> annotation = findAspectJAnnotationOnMethod(method);
  if (annotation == null) {
    return null;
  }
  StringTokenizer nameTokens = new StringTokenizer(annotation.getArgumentNames(), ",");
  if (nameTokens.countTokens() > 0) {
    String[] names = new String[nameTokens.countTokens()];
    for (int i = 0; i < names.length; i++) {
      names[i] = nameTokens.nextToken();
    }
    return names;
  }
  else {
    return null;
  }
}
origin: log4j/log4j

/**
 * Set a string representing the property name/value pairs.
 * 
 * Form: propname1=propvalue1,propname2=propvalue2
 * 
 * @param props
 */
public void setProperties(String props) {
  Map hashTable = new HashMap();
  StringTokenizer pairs = new StringTokenizer(props, ",");
  while (pairs.hasMoreTokens()) {
    StringTokenizer entry = new StringTokenizer(pairs.nextToken(), "=");
    hashTable.put(entry.nextElement().toString().trim(), entry.nextElement().toString().trim());
  }
  synchronized(this) {
    properties = hashTable;
  }
}
origin: pentaho/pentaho-kettle

public String[] getDropStrings( String str, String sep ) {
 StringTokenizer strtok = new StringTokenizer( str, sep );
 String[] retval = new String[ strtok.countTokens() ];
 int i = 0;
 while ( strtok.hasMoreElements() ) {
  retval[ i ] = strtok.nextToken();
  i++;
 }
 return retval;
}
origin: stackoverflow.com

 int stringTokenizer = new StringTokenizer(" " +testString + " ", ".").countTokens()-1;
System.out.println("stringTokenizer = " + stringTokenizer);
origin: prestodb/presto

Rule(StringTokenizer st) {
  if (st.countTokens() < 6) {
    throw new IllegalArgumentException("Attempting to create a Rule from an incomplete tokenizer");
  }
  iName = st.nextToken().intern();
  iFromYear = parseYear(st.nextToken(), 0);
  iToYear = parseYear(st.nextToken(), iFromYear);
  if (iToYear < iFromYear) {
    throw new IllegalArgumentException();
  }
  iType = parseOptional(st.nextToken());
  iDateTimeOfYear = new DateTimeOfYear(st);
  iSaveMillis = parseTime(st.nextToken());
  iLetterS = parseOptional(st.nextToken());
}
origin: marytts/marytts

public static String deblank(String str) {
  StringTokenizer s = new StringTokenizer(str, " ", false);
  StringBuilder strRet = new StringBuilder();
  while (s.hasMoreElements())
    strRet.append(s.nextElement());
  return strRet.toString();
}
origin: libgdx/libgdx

/**
 * Returns the next token in the string as an {@code Object}. This method is
 * implemented in order to satisfy the {@code Enumeration} interface.
 *
 * @return next token in the string as an {@code Object}
 * @throws NoSuchElementException
 *                if no tokens remain.
 */
public Object nextElement() {
  return nextToken();
}
origin: libgdx/libgdx

/**
 * Returns {@code true} if unprocessed tokens remain. This method is
 * implemented in order to satisfy the {@code Enumeration} interface.
 *
 * @return {@code true} if unprocessed tokens remain.
 */
public boolean hasMoreElements() {
  return hasMoreTokens();
}
origin: spring-projects/spring-framework

private static Profiles parseExpression(String expression) {
  Assert.hasText(expression, () -> "Invalid profile expression [" + expression + "]: must contain text");
  StringTokenizer tokens = new StringTokenizer(expression, "()&|!", true);
  return parseTokens(expression, tokens);
}
origin: org.testng/testng

public void setMethodSelectors(String methodSelectors) {
 StringTokenizer st= new StringTokenizer(methodSelectors, " ,");
 while(st.hasMoreTokens()) {
  m_methodselectors.add(st.nextToken());
 }
}
origin: plantuml/plantuml

private double[] parseDoubleArray(String value, String key) {
 try {
  StringTokenizer tokenizer = new StringTokenizer(value);
  double[] result = new double[tokenizer.countTokens()];
  for (int i = 0; i < result.length; i++) {
   result[i] = new Double(tokenizer.nextToken()).doubleValue();
  }
  return result;
 } catch (NumberFormatException e) {
  throw createNumberFormatException("sequence of numbers", value, key);
 }
}
origin: spring-projects/spring-framework

  public static void reset() {
    String s = "UK 123";
    StringTokenizer st = new StringTokenizer(s);
    property = st.nextToken();
  }
}
origin: Vedenin/useful-java-links

@Benchmark
public int stringTokenizer() {
  // Using StringTokenizer
  return new StringTokenizer(" " + testString + " ", ".").countTokens() - 1;
}
java.utilStringTokenizer

Javadoc

Breaks a string into tokens; new code should probably use String#split.
 
// Legacy code: 
StringTokenizer st = new StringTokenizer("a:b:c", ":"); 
while (st.hasMoreTokens()) { 
System.err.println(st.nextToken()); 
} 
// New code: 
for (String token : "a:b:c".split(":")) { 
System.err.println(token); 
} 

Most used methods

  • <init>
    Constructs a string tokenizer for the specified string. All characters in the delim argument are th
  • nextToken
    Returns the next token in this string tokenizer's string. First, the set of characters considered to
  • hasMoreTokens
    Tests if there are more tokens available from this tokenizer's string. If this method returns true,
  • countTokens
    Calculates the number of times that this tokenizer'snextToken method can be called before it generat
  • hasMoreElements
    Returns the same value as the hasMoreTokens method. It exists so that this class can implement theEn
  • nextElement
    Returns the same value as the nextToken method, except that its declared return value is Object rath
  • isDelimiter
  • scanToken
    Skips ahead from startPos and returns the index of the next delimiter character encountered, or maxP
  • setMaxDelimCodePoint
    Set maxDelimCodePoint to the highest char in the delimiter set.
  • skipDelimiters
    Skips delimiters starting from the specified position. If retDelims is false, returns the index of t

Popular in Java

  • Making http post requests using okhttp
  • scheduleAtFixedRate (ScheduledExecutorService)
  • setScale (BigDecimal)
  • getContentResolver (Context)
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • SecureRandom (java.security)
    This class generates cryptographically secure pseudo-random numbers. It is best to invoke SecureRand
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • Runner (org.openjdk.jmh.runner)
  • Logger (org.slf4j)
    The org.slf4j.Logger interface is the main user entry point of SLF4J API. It is expected that loggin
  • Location (org.springframework.beans.factory.parsing)
    Class that models an arbitrary location in a Resource.Typically used to track the location of proble
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now