Tuesday, March 17, 2015

Retrieve values between multiple delimiters






How do we retrieve values between multiple delimiters ?

Consider we have a message as below

"1000000228"       "                                   "     "0                                  "      "9900      " 

 and we have to parse through this string to pick data between the two delimiters. Here in our case it's double codes

So the snippet goes as below

We have declared the string into the variable "msg"

String msg=",\"1000000228\" \"                                   \" \"0   \"  \"9900      \"";   

 String[] elements = msg.split("\"");
for (String element : elements) {
   System.out.println(element);
}

And your output looks as below >>

1000000228

                                   

0   
  
9900      

Kill a port in windows



Many a times we are struck with killing a port in windows unlike we do in Unix. Below is the command you can use to netstat the PID linked to that port and to kill it



> netstat -a -o -n

Above command will list the list of ports and related PID's

> taskkill /F /PID 20760

taskkill will help you kill the port and restart the port again.