I have currently a program that passes a collection of values from an hashmap to another class which stores them as strings. The info stored in the strings is as such:
Station 1=[1, Task 1, 10, false, 0, java.awt.Color[r=255,g=0,b=0]] Station 2=[2, Task 2, 10, false, 0, java.awt.Color[r=0,g=0,b=255]] Station 3=[3, Task 3, 10, false, 0, java.awt.Color[r=0,g=255,b=0]] Station 4=[4, Task 4, 10, false, 0, java.awt.Color[r=255,g=200,b=0]] Station 5=[5, Task 5, 10, false, 0, java.awt.Color[r=0,g=0,b=0]] And I am trying to split them into (f.e.):
Station 1 1 Task 1 10 false 0 java.awt.Color[r=255,g=0,b=0] I've first tried splitting each string but as there are "=" and "," on the last part of the string where the color value is set it gets all messed up.
I've also tried StringTokenizer() but I get problems on the last part aswell.
Is there an easier or effective way to split these strings as needed? Any suggestions are welcome!
Thanks in advance for your time and let me know if code is needed!
EDIT:
I have fixed my particular problem by passing the arguments correctly from the hashmaps.
public MultiMap stationmap = new MultiHashMap( ); public Collection getkeyValues(String s) { Collection values = (Collection) stationmap.get(s); return values; } This way, I can pass this collection to the class where I need them, and I can further iterate over it to get the values for the keys.
I'll leave this open as further answers might help people with similar string problems!