Sunday, 2 December 2018

Java extract numbers from a Strimg and add Preceeding zeros to it

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

Pass a HashMap from Angular Client to Spring boot API

This example is for the case where fileData is very huge and in json format   let map = new Map<string, string>()      map.set(this.ge...