File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Convert String to ArrayList

 
shailesh kumar
Ranch Hand
Posts: 36
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have requirement where the user will paste these codes in the text area from the front end and I need to convert this string to Arraylist, can any body please help me with this..
-----------
222222
333333
444444
555555
666666
777777
888888
999999
-----------

This whole numbers come as String to and need to convert to Arraylist, i treid some ways but iam not successfull.
 
Steve Morrow
Ranch Hand
Posts: 657
Clojure Spring VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check the API for String.split() and Arrays.asList().
 
shailesh kumar
Ranch Hand
Posts: 36
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI Steve,
I used the same methods..but here is the result..

String[] outPut = null;

outPut = barcodePaste.split("/n");

// barcodePaste is coming from front end as String

But when I do outPut[1], it returns Index out bound exception, If I call outPut[0] it returns the entire string again. Its not adding to the array on index by index, how do I do that??
 
Steve Morrow
Ranch Hand
Posts: 657
Clojure Spring VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The newline character is "\n".
 
shailesh kumar
Ranch Hand
Posts: 36
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh ! thanks Steve !!, that was really silly mistake...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic