I had a little problem with casting Java long type to Enum type and can't find a solution how to do that.
Here is what I'm using :
public enum DataType {
IMAGES(1),
VIDEOS(2);
private int value;
private DataType(int i){
this.value = i;
}
}
and I need to do something like this:
DataType dataType;
String thiz = "1";
long numb = Long.parseLong(thiz);
dataType = numb;
The error that I get says:
Convert numb to DataType or convert dataType to long.
Second Scenario:
I have this :
static String[] packetType;
String tmp=incomingData.toString(); // where incomingData is byte[]
int lastLoc = 0;
int needsSize = packetFieldSizes[tmpCurrentField-1]; // where packetFieldSizes,tmpCurrentField are integers.
thiz=tmp.substring(lastLoc, needsSize);
packetType=thiz; // packetType = thiz copy; where thiz is the same as used above.
I tried to convert thiz to String[] and use valueOf,but
Any suggestions how to get the thinks to work?
Thanks in advance!