Do this:
long l = Long.parseLong(str);
However, always check that str contains digits to prevent throwing exceptions.
For instance:
String str="ABCDE";
long l = Long.parseLong(str);
would throw an exception but this
String str="1234567";
long l = Long.parseLong(str);
won't.