Tabnine Logo
String.split
Code IndexAdd Tabnine to your IDE (free)

How to use
split
method
in
java.lang.String

Best Java code snippets using java.lang.String.split (Showing top 20 results out of 195,957)

origin: stackoverflow.com

 String string = "004-034556";
String[] parts = string.split("(?<=-)");
String part1 = parts[0]; // 004-
String part2 = parts[1]; // 034556
origin: stackoverflow.com

 String string = "004-034556";
String[] parts = string.split("-");
String part1 = parts[0]; // 004
String part2 = parts[1]; // 034556
origin: stackoverflow.com

 String string = "004-034556";
String[] parts = string.split("(?=-)");
String part1 = parts[0]; // 004
String part2 = parts[1]; // -034556
origin: stackoverflow.com

 String string = "004-034556-42";
String[] parts = string.split("-", 2);
String part1 = parts[0]; // 004
String part2 = parts[1]; // 034556-42
origin: stackoverflow.com

 String contentType = connection.getHeaderField("Content-Type");
String charset = null;

for (String param : contentType.replace(" ", "").split(";")) {
  if (param.startsWith("charset=")) {
    charset = param.split("=", 2)[1];
    break;
  }
}

if (charset != null) {
  try (BufferedReader reader = new BufferedReader(new InputStreamReader(response, charset))) {
    for (String line; (line = reader.readLine()) != null;) {
      // ... System.out.println(line) ?
    }
  }
} else {
  // It's likely binary content, use InputStream/OutputStream.
}
origin: stackoverflow.com

 // Gather all cookies on the first request.
URLConnection connection = new URL(url).openConnection();
List<String> cookies = connection.getHeaderFields().get("Set-Cookie");
// ...

// Then use the same cookies on all subsequent requests.
connection = new URL(url).openConnection();
for (String cookie : cookies) {
  connection.addRequestProperty("Cookie", cookie.split(";", 2)[0]);
}
// ...
origin: spring-projects/spring-framework

@Override
public MyCustomElement unmarshal(String c) throws Exception {
  String[] t = c.split("\\|\\|\\|");
  return new MyCustomElement(t[0], t[1]);
}
origin: ReactiveX/RxJava

  @Override
  public Flowable<String> apply(Resource resource) {
    return Flowable.fromArray(resource.getTextFromWeb().split(" "));
  }
};
origin: ReactiveX/RxJava

  @Override
  public Flowable<String> apply(Resource res) {
    return Flowable.fromArray(res.getTextFromWeb().split(" "));
  }
};
origin: ReactiveX/RxJava

  @Override
  public Flowable<String> apply(Resource resource) {
    return Flowable.fromArray(resource.getTextFromWeb().split(" "));
  }
};
origin: ReactiveX/RxJava

  @Override
  public Observable<String> apply(Resource res) {
      return Observable.fromArray(res.getTextFromWeb().split(" "));
  }
};
origin: ReactiveX/RxJava

  @Override
  public Observable<String> apply(Resource resource) {
    return Observable.fromArray(resource.getTextFromWeb().split(" "));
  }
};
origin: ReactiveX/RxJava

  @Override
  public Flowable<String> apply(Resource res) {
      return Flowable.fromArray(res.getTextFromWeb().split(" "));
  }
};
origin: ReactiveX/RxJava

  @Override
  public Observable<String> apply(Resource res) {
    return Observable.fromArray(res.getTextFromWeb().split(" "));
  }
};
origin: ReactiveX/RxJava

  @Override
  public Observable<String> apply(Resource resource) {
    return Observable.fromArray(resource.getTextFromWeb().split(" "));
  }
};
origin: google/guava

public void testComputeIfPresent() {
 cache.put(key, "1");
 // simultaneous update for same key, expect count successful updates
 doParallelCacheOp(
   count,
   n -> {
    cache.asMap().computeIfPresent(key, (k, v) -> v + delimiter + n);
   });
 assertEquals(1, cache.size());
 assertThat(cache.getIfPresent(key).split(delimiter)).hasLength(count + 1);
}
origin: ReactiveX/RxJava

  @Override
  public Observable<String> apply(Resource resource) {
    return Observable.fromArray(resource.getTextFromWeb().split(" "))
        .concatWith(Observable.<String>error(new RuntimeException()));
  }
};
origin: ReactiveX/RxJava

  @Override
  public Flowable<String> apply(Resource resource) {
    return Flowable.fromArray(resource.getTextFromWeb().split(" "))
        .concatWith(Flowable.<String>error(new RuntimeException()));
  }
};
origin: ReactiveX/RxJava

  @Override
  public Observable<String> apply(Resource resource) {
    return Observable.fromArray(resource.getTextFromWeb().split(" "))
        .concatWith(Observable.<String>error(new RuntimeException()));
  }
};
origin: ReactiveX/RxJava

  @Override
  public Flowable<String> apply(Resource resource) {
    return Flowable.fromArray(resource.getTextFromWeb().split(" "))
        .concatWith(Flowable.<String>error(new RuntimeException()));
  }
};
java.langStringsplit

Javadoc

Splits this string around matches of the given regular expression.

This method works as if by invoking the two-argument #split(String,int) method with the given expression and a limit argument of zero. Trailing empty strings are therefore not included in the resulting array.

The string "boo:and:foo", for example, yields the following results with these expressions:

Regex Result
: { "boo", "and", "foo" }
o { "b", "", ":and:f" }

Popular methods of String

  • equals
  • length
    Returns the number of characters in this string.
  • substring
    Returns a string containing a subsequence of characters from this string. The returned string shares
  • startsWith
    Compares the specified string to this string, starting at the specified offset, to determine if the
  • format
    Returns a formatted string, using the supplied format and arguments, localized to the given locale.
  • trim
  • valueOf
    Creates a new string containing the specified characters in the character array. Modifying the chara
  • indexOf
  • endsWith
    Compares the specified string to this string to determine if the specified string is a suffix.
  • toLowerCase
    Converts this string to lower case, using the rules of locale.Most case mappings are unaffected by t
  • contains
    Determines if this String contains the sequence of characters in the CharSequence passed.
  • getBytes
  • contains,
  • getBytes,
  • <init>,
  • equalsIgnoreCase,
  • replace,
  • isEmpty,
  • charAt,
  • hashCode,
  • lastIndexOf

Popular in Java

  • Finding current android device location
  • onCreateOptionsMenu (Activity)
  • notifyDataSetChanged (ArrayAdapter)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • MessageFormat (java.text)
    Produces concatenated messages in language-neutral way. New code should probably use java.util.Forma
  • JComboBox (javax.swing)
  • Join (org.hibernate.mapping)
  • Top PhpStorm 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