Although you cannot just cast a String to a long, you
can parse out the value of a String that contains a
number and convert that to a long. You can use the
Long wrapper class and your code would look somewhat
like this:
try
{
String myString = "1234";
long myLong = Long.parseLong(myString);
}
catch (NumberFormatException nfe)
{
// handle the exception however appropriate...
// e.g.
nfe.printStackTrace();
}