0

How can I split a string in java inclusive of white spaces?

String test = "1\t0.000000000\t192.168.0.24\t\t10.0.0.5\t\t98\t84\t\t\t\t\t\t\t\t1";

The output array list should be like:

["1"," ","0.000000000", " ","192.168.0.24", " ", " ","10.0.0.5"...(well you get me)]
azurefrog
  • 10,785
  • 7
  • 42
  • 56
vicmerbia
  • 1
  • 2

1 Answers1

0

Try this.

      String text = "1\t0.000000000\t192.168.0.24\t\t10.0.0.5\t\t98\t84\t\t\t\t\t\t\t\t1";

      String[] result = text.replaceAll("\t", "\t \t").split("(\t)+");

SternK
  • 11,649
  • 22
  • 32
  • 46