I would like to convert java.awt.color object to string.
Color c = new Color(255,0,0);
System.out.print(Color.toString);
It prints java.awt.Color[r=255,g=0,b=0]
Now I suppose to parse this string and decode the color name e.g blue etc.
I was thinking is there any other way I can directly convert this Color into String.
Thanks in advance.
EDIT: I would like to store this color values in database. Should I store it as a String or RGB value?
No. At least because:
But you can do otherwise. Get the predefined constants in
Colorand check if any of them has the same RGB as the given color. If so – print the name.As for your added question – store it as RGB value rather than string.