public class ExtractnumberFromString {
public static void main(String[] args) {
String s = "TEST002";
s = s.replaceAll("\\D+","");
String res = s.replaceAll("\\D+","");
System.out.println("Numeric is "+res);
String formatted = String.format("%6s", Integer.toBinaryString(Integer.parseInt(res))).replace(" ", "0");
System.out.println("binary is "+formatted);
}
}
No comments:
Post a Comment