0

please, I have problem with parsing line in file by pipe (|) delimiter in Java.

I have this line:

4||AD3451059||||||||||||||||||||||1040374.670831981|739638.7683246896|50.11484423280666|14.460148189573438||||||

I'm trying it parse in Java using:

String[] params = line.split(Pattern.quote("|"));

But I also tried:

String[] params = line.split("\\|");

The line has 34 parameters (index 0 - 33) but array params has just 28 parameters (index 0 - 27).

System.out.println("Line: " + String.valueOf(i) + " has " + String.valueOf(params.length) + " parameters." );

outputs: Line: 17 has 28 parameters.

For example, this line works perfectly:

1||AD00000|CZ|Prague|19|Prague|3100|Prague|554782|||||||Street|489930|||||District||1048025.7908252006|751353.7683138615|50.032290186813704|14.31264367762477|0|0||false||

The line above has 34 parameters which is true. How it's possible please?

Is the possible, that after index 27 i have just | and nothing more to the of the line? How can I parse it regular please? Thank you very much

Best regards

Bambi Bunny
  • 1,008
  • 2
  • 9
  • 18

0 Answers0