I take the String variable from the request.
String issueField = request.getParameter("issueno");
It may or may not have a hyphen in the middle. I want to be able to iterate through String and divide the string when a hyphen is displayed.
Use String # split:
String[] parts = issueField.split("-");
Then you can use parts[0]to get the first part, parts[1]for the second, ...
parts[0]
parts[1]
String.split
String.split , Guava Splitter , API , :
http://guava-libraries.googlecode.com/svn/trunk/javadoc/com/google/common/base/Splitter.html
, :
Iterable<String> parts = Splitter.on('-').split(issueField);
Splitter String.split:
Iterable
The only reason not to use Splitter is if you do not want to include Guava in your classpath.
You can also use the java.util.StringTokenizer class. Although String.split is a simpler and more suitable way for your problem.
Source: https://habr.com/ru/post/1791411/More articles:Производительность С++: проверка блока памяти на наличие определенных значений в определенных ячейках - c++Free IDE Icons? - designПользовательские графические объекты, не работающие в библиотечных проектах - androidHow to create a primary key (automatically generated sequence) in apache cassandra - cassandra__clone () vs unserialize (serialize ())? - clonehow to get all ListBox items (not just selected items) to send an action to mvc - c #Prevent Multiple Concurrent Logins - asp.netWIX: saving user input in xml file - wixHow to get the MIME type of file to download? - mime-typesCLocationManager - how to call kCLErrorNetwork - iosAll Articles