How to split HTML textarea element into array of lines in Java
-
How to split HTML textarea element into array of lines in Java
-
Answer:
If you mean Java and not Javascript (assuming you have a JSP system): String[] lines = myTextArea.getText().split("\\n"); or String[] lines = request.getParameter("textarea").split("\\n"); Edited down: For javascript: var lines = document.getElementById("myTextArea").value.split('\\n');
Svet at Stack Overflow Visit the source
Other answers
In Java, get the text and pass it to a method like: private String[] split(String s) { if (s==null) { return new String[0]; } StringTokenizer st = new StringTokenizer(s,"\n"); ArrayList list = new ArrayList(); while (st.hasMoreElements()) { list.add(st.nextToken()); } return (String[]) list.toArray(new String[list.size()]); }
Bruno Rothgiesser
Related Q & A:
- How To Split DVD?Best solution by Yahoo! Answers
- Is HTML meta element effective to increase a site's search ranking?Best solution by Webmasters
- How to split a string in C++?Best solution by Stack Overflow
- How to split column text to another column?Best solution by Stack Overflow
- How to completely remove TextArea Verical ScrollBar?Best solution by css-tricks.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.